Skip to content

Instantly share code, notes, and snippets.

@amirnissim
Last active August 29, 2015 14:10
Show Gist options
  • Save amirnissim/0c133e73439a5b1e30f4 to your computer and use it in GitHub Desktop.
Save amirnissim/0c133e73439a5b1e30f4 to your computer and use it in GitHub Desktop.
Simple Tornado server sending 500 reponses
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