Exemple #1
0
def main():
    parse_command_line()

    init_db()           # 初始化数据库
    cahe_accounts()     # 缓存账户数据到内存

    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(options.port)
    print 'Server is running at http://127.0.0.1:%s/' % options.port
    print 'Quit the server with Control-C'
    tornado.ioloop.IOLoop.instance().start()
Exemple #2
0
def main():
    parse_command_line()

    init_db()  # 初始化数据库
    cahe_accounts()  # 缓存账户数据到内存

    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(options.port)
    print 'Server is running at http://127.0.0.1:%s/' % options.port
    print 'Quit the server with Control-C'
    tornado.ioloop.IOLoop.instance().start()
Exemple #3
0
        # fh = open(__UPLOADS__ + cname, 'wb')
        # fh.write(body)

        q = Auth(config.QINIU_AK, config.QINIU_SK)
        key = 'upload/' + cname
        token = q.upload_token(config.QINIU_BUCKET_NAME)
        ret, info = put_data(token, key, body)

        if info.status_code == 200:
            self.finish("图片已上传,图片地址为: %s" % ("http://7xobq7.com2.z0.glb.qiniucdn.com/" + key))
        else:
            self.finish("图片上传失败: %s" % str(ret))


if __name__ == '__main__':
    vote_model.init_db()

    import uimodule
    settings = {
        "static_path": os.path.join(os.path.dirname(__file__), "static"),
        "cookie_secret": "61oETzKXQAGaYdk12345GeJJFuYh7EQnp2XdTP1o/Vo=",
        "login_url": "/login",
        "ui_modules": uimodule,
    }

    application = Application([
        (r'/', tornado.web.RedirectHandler, {"url": "/login", "permanent": False}),
        (r"/login", LoginHandler),
        (r"/logout", LogoutHandler),
        (r"/reload_cache", ReloadCacheHandler),