find-object-bundle-builder/FindObjectBundleBuilder/Tools/server/find_object_firebase_server.py

42 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/python
# coding:utf-8
import sys
# 导入Tornado模块
import tornado.ioloop # 核心IO循环模块
import tornado.httpserver # 异步非阻塞HTTP服务器模块
import tornado.web # Web框架模块
import tornado.options # 解析终端参数模块
# 从终端模块中导出define模块用于读取参数导出options模块用于设置默认参数
from tornado.options import define, options
from handler.firebase_storage import FirebaseStorageHandler
# 定义端口用于指定HTTP服务监听的端口
# 如果命令行中带有port同名参数则会称为全局tornado.options的属性若没有则使用define定义。
define("port", type=int, default=5003, help="run on the given port")
# 创建路由表
urls = [
(r"/guru/fs", FirebaseStorageHandler, dict(data="database"))
]
# 定义服务器
def main():
# 解析命令行参数
tornado.options.parse_command_line()
# 创建应用实例
app = tornado.web.Application(urls)
print("127.0.0.1 listening " + str(options.port))
# 监听端口
app.listen(options.port)
# 创建IOLoop实例并启动
tornado.ioloop.IOLoop.current().start()
# 应用运行入口,解析命令行参数
if __name__ == "__main__":
# 启动服务器
main()