Created
October 10, 2018 12:32
-
-
Save loretoparisi/6aa084febdbf8fd1790cbb06badae833 to your computer and use it in GitHub Desktop.
Python Tornado simple WSGI Application
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
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