You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
# -*- coding: utf-8 -*-
|
|
"""
|
|
web
|
|
~~~~~~~~~~~~~~
|
|
|
|
整个项目的入口,测试时可用python web.py启动项目.
|
|
|
|
:copyright: 云南新八达科技有限公司.
|
|
:author: 李进才.
|
|
"""
|
|
from flask import Flask, url_for, redirect, request
|
|
from logging.config import dictConfig
|
|
from flask_cors import CORS
|
|
from api.user import *
|
|
from error import exception
|
|
from waitress import serve
|
|
|
|
dictConfig({
|
|
'version': 1,
|
|
'formatters': {'default': {
|
|
'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s',
|
|
}},
|
|
'handlers': {'wsgi': {
|
|
'class': 'logging.StreamHandler',
|
|
'stream': 'ext://flask.logging.wsgi_errors_stream',
|
|
'formatter': 'default'
|
|
}},
|
|
'root': {
|
|
'level': 'INFO',
|
|
'handlers': ['wsgi']
|
|
}
|
|
})
|
|
|
|
# 测试内容写法
|
|
# with app.test_request_context():
|
|
# print(ResultCode.SUCCESS.value['code'])
|
|
# 注册蓝图,并指定其对应的前缀(url_prefix)
|
|
app.register_blueprint(exception, url_prefix='/error')
|
|
|
|
cors = CORS(app, resources={r"/*": {"origins": "*"}})
|
|
if __name__ == '__main__':
|
|
serve(app, host="0.0.0.0", port=9900)
|
|
|