eventman/eventman_server.py

44 lines
1.2 KiB
Python
Raw Normal View History

2015-03-14 11:12:57 +01:00
#!/usr/bin/env python
"""Event Man(ager)
Your friendly manager of attendants at a conference.
"""
import os
import tornado.httpserver
import tornado.ioloop
import tornado.options
from tornado.options import define, options
import tornado.web
2015-03-14 13:05:04 +01:00
from tornado import gen
2015-03-14 11:12:57 +01:00
class MainHandler(tornado.web.RequestHandler):
2015-03-14 13:05:04 +01:00
@gen.coroutine
2015-03-14 11:12:57 +01:00
def get(self):
2015-03-14 13:05:04 +01:00
self.redirect('/static/html/index.html')
2015-03-14 11:12:57 +01:00
def main():
define("port", default=5242, help="run on the given port", type=int)
define("config", help="read configuration file",
callback=lambda path: tornado.options.parse_config_file(path, final=False))
define("debug", default=False, help="run in debug mode")
tornado.options.parse_command_line()
application = tornado.web.Application([
2015-03-14 13:05:04 +01:00
(r"/(?:index.html)?", MainHandler),
2015-03-14 11:12:57 +01:00
],
2015-03-14 13:05:04 +01:00
template_path=os.path.join(os.path.dirname(__file__), "templates"),
2015-03-14 11:12:57 +01:00
static_path=os.path.join(os.path.dirname(__file__), "static"),
2015-03-14 13:05:04 +01:00
debug=options.debug)
2015-03-14 11:12:57 +01:00
http_server = tornado.httpserver.HTTPServer(application)
2015-03-14 11:22:19 +01:00
http_server.listen(options.port)
2015-03-14 11:12:57 +01:00
tornado.ioloop.IOLoop.instance().start()
if __name__ == '__main__':
main()