mirror of
https://github.com/xfgryujk/blivechat.git
synced 2026-08-19 09:43:28 +08:00
添加命令行选项
This commit is contained in:
30
main.py
30
main.py
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
|
||||
@@ -21,21 +22,32 @@ class MainHandler(tornado.web.StaticFileHandler):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='用于OBS的仿YouTube风格的bilibili直播聊天层')
|
||||
parser.add_argument('--host', help='服务器host,默认为127.0.0.1', default='127.0.0.1')
|
||||
parser.add_argument('--port', help='服务器端口,默认为80', type=int, default=80)
|
||||
parser.add_argument('--debug', help='调试模式', action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(
|
||||
format='{asctime} {levelname} [{name}]: {message}',
|
||||
datefmt='%Y-%m-%d %H:%M:%S',
|
||||
style='{',
|
||||
level=logging.INFO
|
||||
level=logging.INFO if not args.debug else logging.DEBUG
|
||||
)
|
||||
|
||||
app = tornado.web.Application([
|
||||
(r'/chat', chat.ChatHandler),
|
||||
(r'/((css|img|js)/.*)', tornado.web.StaticFileHandler, {'path': WEB_ROOT}),
|
||||
(r'/(favicon\.ico)', tornado.web.StaticFileHandler, {'path': WEB_ROOT}),
|
||||
(r'/.*', MainHandler, {'path': WEB_ROOT})
|
||||
], websocket_ping_interval=30)
|
||||
app.listen(80, '127.0.0.1')
|
||||
logger.info('服务器启动:127.0.0.1:80')
|
||||
app = tornado.web.Application(
|
||||
[
|
||||
(r'/chat', chat.ChatHandler),
|
||||
(r'/((css|img|js)/.*)', tornado.web.StaticFileHandler, {'path': WEB_ROOT}),
|
||||
(r'/(favicon\.ico)', tornado.web.StaticFileHandler, {'path': WEB_ROOT}),
|
||||
(r'/.*', MainHandler, {'path': WEB_ROOT})
|
||||
],
|
||||
websocket_ping_interval=30,
|
||||
debug=args.debug,
|
||||
autoreload=False
|
||||
)
|
||||
app.listen(args.port, args.host)
|
||||
logger.info('服务器启动:%s:%d', args.host, args.port)
|
||||
tornado.ioloop.IOLoop.current().start()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user