Created
August 18, 2017 12:49
-
-
Save goodrahstar/948253dc9f7bc441510f50a85e005d0b to your computer and use it in GitHub Desktop.
Serving Predictions code using webpy to create a RESTful API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """ | |
| @author: Rahul.kumar | |
| """ | |
| import web | |
| #import sys,os | |
| import json | |
| import sentiment_model as model | |
| urls = ('/sentiment', 'Sentiment') | |
| app = web.application(urls, globals()) | |
| class Sentiment: | |
| def GET(self): | |
| web.header('Content-Type', 'application/json') | |
| user_data = web.input() | |
| comment= user_data.message | |
| # senderid= user_data.senderid | |
| # senderName= user_data.senderName | |
| sentiment = model.engine(query = comment , senderid='Rahul', senderName='Rahul') | |
| return json.dumps(sentiment ) | |
| if __name__ == "__main__": | |
| app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment