Created
October 5, 2018 13:28
-
-
Save RichardBray/d93b557c569fc3e9fe7f4746ad891db7 to your computer and use it in GitHub Desktop.
This file contains 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
from tornado.web import Application, RequestHandler | |
from tornado.ioloop import IOLoop | |
items = [] | |
class TodoItems(RequestHandler): | |
def get(self): | |
self.write({'items': items}) | |
class TodoItem(RequestHandler): | |
def post(self): | |
items.append(self.request.body) | |
self.write({'message': self.request.body}) | |
def make_app(): | |
urls = [ | |
("/", TodoItems), | |
("/api/item/", TodoItem) | |
] | |
return Application(urls, debug=True) | |
if __name__ == '__main__': | |
app = make_app() | |
app.listen(3000) | |
IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment