Skip to content

Instantly share code, notes, and snippets.

@goodrahstar
Created August 18, 2017 12:49
Show Gist options
  • Select an option

  • Save goodrahstar/948253dc9f7bc441510f50a85e005d0b to your computer and use it in GitHub Desktop.

Select an option

Save goodrahstar/948253dc9f7bc441510f50a85e005d0b to your computer and use it in GitHub Desktop.
Serving Predictions code using webpy to create a RESTful API.
# -*- 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