Created
October 15, 2019 13:11
-
-
Save VictorZhang2014/2deeb3312fa72ebe73d111dad22cd0dd 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
import tornado.ioloop | |
import tornado.web | |
import os | |
from tornado.options import define, options | |
define("port", default=8100, help="run on the given port", type=int) | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
# The `index.html` is located in `templates` folder | |
self.render("index.html") | |
def make_app(): | |
settings = dict( | |
template_path=os.path.join(os.path.dirname(__file__), "templates"), | |
static_path=os.path.join(os.path.dirname(__file__), "static"), | |
) | |
return tornado.web.Application( | |
[(r"/", MainHandler)], | |
**settings | |
) | |
if __name__ == "__main__": | |
tornado.options.parse_command_line() | |
app = make_app() | |
http_server = tornado.httpserver.HTTPServer(app) | |
http_server.listen(options.port) | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment