Last active
August 29, 2015 14:10
-
-
Save amirnissim/0c133e73439a5b1e30f4 to your computer and use it in GitHub Desktop.
Simple Tornado server sending 500 reponses
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
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.web | |
class Handler(tornado.web.RequestHandler): | |
def error(self): | |
self.set_header("Access-Control-Allow-Credentials", "true") | |
self.set_header("Access-Control-Allow-Origin", "") | |
self.set_header("Access-Control-Allow-Methods", "GET, POST") | |
self.set_status(500) | |
self.write('Server Error') | |
def get(self): | |
self.error() | |
def post(self): | |
self.error() | |
app = tornado.web.Application([ | |
(r".+", Handler), | |
]) | |
if __name__ == "__main__": | |
# uncomment for HTTPS | |
# server = tornado.httpserver.HTTPServer(app, ssl_options={ | |
# "certfile": "my.cert", | |
# "keyfile": "my.key" | |
# }) | |
# server.listen(443) | |
app.listen(80) | |
tornado.ioloop.IOLoop.instance().start() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment