Advertisement
vinissh

python_back_end

Jan 8th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import tornado.web
  2. import tornado.ioloop
  3. import json
  4.  
  5. class listRequestHandler(tornado.web.RequestHandler):
  6.     def get(self):
  7.         fh = open("list.txt", "r")
  8.         fruits = fh.read().splitlines()
  9.         fh.close()
  10.         self.write(json.dumps(fruits))
  11.        
  12. if __name__ == "__main__":
  13.     app = tornado.web.Application([
  14.         (r"/list", listRequestHandler)
  15.     ])
  16.    
  17.     port = 8882
  18.     app.listen(port)
  19.     print(f"Application is ready and listening on port {port}")
  20.     tornado.ioloop.IOLoop.current().start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement