import time
import tornado.ioloop
import tornado.web
from tornado import gen, concurrent
import json
class MainHandler(tornado.web.RequestHandler):
# @gen.coroutine
# def get(self):
# l = ['Ram', 'Shyam', 'Sita', 'Lakshman']
# v = random.choice(l)
# yield self.write("Hello, world --> " + v)
@gen.coroutine
# @concurrent.run_on_executor(executor='_thread_pool')
def post(self):
print(self )
# req_data = (json.loads(self.request.body))
print(self.request.body)
req_data = (json.loads(self.request.body.decode('utf-8')))
# # print("inside the post request")
channelID = req_data["channelId"]
print("channelid :"+ channelID)
self.set_header("Content-Type", "text/plain")
yield self.write(channelID)
def make_app():
return tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
app = make_app()
print("inside server initiation")
app.listen(5006, '0.0.0.0')
tornado.ioloop.IOLoop.current().start()
Comments
Post a Comment