代码拉取完成,页面将自动刷新
#!/usr/bin/env python
# encoding: utf-8
"""
@version: v1.0
@author: konglingxi
@contact: 1319328276@qq.com
@software: PyCharm
@file: manage.py
@time: 2019/9/18 22:30
"""
from __future__ import unicode_literals
import os
import tornado.web
import tornado.ioloop
from tornado.options import parse_command_line, define, options
from apps.chat_views import ChatHandler, NewChatHandler
from apps.user_views import RegisterHandler, LoginHandler
from apps.views import IndexHandler, CreateDbHandler, DropDbHandler, TestHandler
from utils.chat_websocket import ChatWebSocket
define('port', default=80, type=int, help='host port')
class Application(tornado.web.Application):
def __init__(self):
self.chatWebSocket = ChatWebSocket()
if not os.path.exists(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')):
os.makedirs(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'))
if not os.path.exists(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')):
os.makedirs(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static'))
handlers = [
(r'/$', IndexHandler),
(r'/test/', TestHandler),
(r'/create-db/', CreateDbHandler),
(r'/drop-db/', DropDbHandler),
(r'/register/', RegisterHandler),
(r'/login/', LoginHandler),
(r'/chat/', ChatHandler),
(r'/new-chat/', NewChatHandler),
]
settings = {
'template_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'),
'static_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static'),
}
tornado.web.Application.__init__(self, handlers, **settings)
if __name__ == '__main__':
address = '127.0.0.1'
# 读取命令行参数
parse_command_line()
# 实例化应用
app = Application()
# 监听端口
app.listen(options.port, address=address)
# 启动
print('Starting development server at http://{}:{}/'.format(address, options.port))
tornado.ioloop.IOLoop.current().start()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。