You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1000 B
41 lines
1000 B
|
|
import os
|
|
|
|
import tornado.httpserver
|
|
import tornado.ioloop
|
|
import tornado.options
|
|
import tornado.web
|
|
|
|
from tornado.options import define, options
|
|
|
|
define("port", default=8888, help="run on the given port", type=int)
|
|
|
|
class MainHandler(tornado.web.RequestHandler):
|
|
def get(self):
|
|
self.render('notebook.html')
|
|
|
|
|
|
class NotebookApplication(tornado.web.Application):
|
|
def __init__(self):
|
|
handlers = [
|
|
(r"/", MainHandler)
|
|
]
|
|
settings = dict(
|
|
template_path=os.path.join(os.path.dirname(__file__), "templates"),
|
|
static_path=os.path.join(os.path.dirname(__file__), "static"),
|
|
)
|
|
tornado.web.Application.__init__(self, handlers, **settings)
|
|
|
|
|
|
def main():
|
|
tornado.options.parse_command_line()
|
|
application = NotebookApplication()
|
|
http_server = tornado.httpserver.HTTPServer(application)
|
|
http_server.listen(options.port)
|
|
tornado.ioloop.IOLoop.instance().start()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|