from flask import Flask
from app.config import Config
from app.routes import user_routes, chat_routes
def create_app():
app = Flask(__name__)
app.config.from_object(Config)
app.register_blueprint(user_routes.bp)
app.register_blueprint(chat_routes.bp)
return app
if __name__ == "__main__":
app = create_app()
app.run(debug=True)
启动文件说明
create_app(): 创建并配置Flask应用实例,注册蓝图(Blueprints)。
if __name__ == "__main__":: 当文件作为主程序运行时,启动应用。
3. 项目的配置文件介绍
app/config.py
import os
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///app.db'
SQLALCHEMY_TRACK_MODIFICATIONS = False
Tchatchers 开源项目使用教程 tchatcherstchatchers is a blazing fast chat application built with Axum and Yew.rs项目地址:https://gitcode.com/gh_mirrors/tc/tchatchers 1. 项目的目录结构及介绍tchatchers/├── README.md├── app...