Skip to content

Instantly share code, notes, and snippets.

@loretoparisi
Created October 10, 2018 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loretoparisi/6aa084febdbf8fd1790cbb06badae833 to your computer and use it in GitHub Desktop.
Save loretoparisi/6aa084febdbf8fd1790cbb06badae833 to your computer and use it in GitHub Desktop.
Python Tornado simple WSGI Application
def application():
handlers=[
## Error handler
#(r"/", ErrorHandler),
######INDEX
(r'/', indexHandler.IndexHandler),
]
settings=dict()
return tornado.wsgi.WSGIApplication(handlers, **settings)
app = application()
if __name__ == "__main__":
# retrieve env config
PORT = os.getenv('PORT', 8888)
DIST = os.getenv('DIST', 'prod')
access_log = logging.getLogger("tornado.access")
app_log = logging.getLogger("tornado.application")
gen_log = logging.getLogger("tornado.general")
logging_config = dict(
version = 1,
formatters = {
'f': {'format':
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s'}
},
handlers = {
'h': {'class': 'logging.StreamHandler',
'formatter': 'f',
'level': logging.DEBUG}
},
loggers = {
'tornado.general': {'handlers': ['h'],
'level': logging.DEBUG}
}
)
dictConfig(logging_config)
#enable_pretty_logging()
http_server = HTTPServer( WSGIContainer(app) )
http_server.listen(int(PORT))
logger.info('Http Server listening on Port %s ' % PORT)
ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment