#
# Command-line parsing
#
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8000, help="run on the given
port", type=int)
define("nopnop2002", default="/tmp", help="run on the
given directory", type=str)
define("memcache_hosts", default="127.0.0.1:11011",
multiple=True,
help="Main user
memcache servers")
define("config", type=str,
help="path to config file",
callback=lambda
path: options.parse_config_file(path, final=False))
class Application(tornado.web.Application):
def __init__(self):
print("nopnop2002={}".format(options.nopnop2002))
print("memcache_hosts={}".format(options.memcache_hosts))
handlers =
[
(r"/", IndexHandler),
]
settings =
dict(
debug=True,
)
tornado.web.Application.__init__(self, handlers,
**settings)
class IndexHandler(tornado.web.RequestHandler):
def get(self):
param =
self.get_argument('param', 'Hello World')
self.write(param)
if __name__ == "__main__":
tornado.options.parse_command_line()
#tornado.options.parse_config_file("server.conf")
#app =
tornado.web.Application([(r"/",
IndexHandler)],debug=True)
app = Application()
http_server =
tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.current().start()
|