def create_app(): # 生成app app = Flask(__name__) # 配置views set_up_views(app) # 初始化APP AppUtils.init(app) return app
def create_app(): # 配置 pywsgi # dapp = DebuggedApplication(app, evalex=True) # server = pywsgi.WSGIServer(('0.0.0.0', 5000), dapp) # server.serve_forever() # 运行 flask # 猴子补丁,增加并发 # monkey.patch_all() # 生成app app = Flask(__name__) # 配置views set_up_views(app) # 初始化APP AppUtils.init(app) return app
# 猴子补丁,增加并发 dotenv_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '.env') if os.path.exists(dotenv_path): load_dotenv(dotenv_path, override=True) # override=True: 覆写已存在的变量 from app_utils import AppUtils from router import app_router monkey.patch_all() # 生成app app = Flask(__name__) # 初始化APP AppUtils.init(app) # 配置API app_router.set_up_api(app) @app.route('/') def index_page(): return render_template("index.html") # def start_server(): # 配置 pywsgi dapp = DebuggedApplication(app, evalex=True) server = pywsgi.WSGIServer(('0.0.0.0', 5000), dapp) server.serve_forever()