Files
Skit-Panel/backend/app.py
DengDai 519589f8f5 init
2025-12-08 14:45:14 +08:00

36 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# skit_panel_backend/app.py
from flask import Flask
from flask_cors import CORS
# 导入蓝图
from routes.dashboard import dashboard_bp
from routes.system import system_bp
from routes.media import media_bp
from routes.actions import actions_bp
from services.scheduler_service import init_scheduler
def create_app():
app = Flask(__name__)
# 配置 CORS允许你的前端地址访问
# 在开发中, "*" 是最简单的设置
CORS(app, resources={r"/api/*": {"origins": "*"}})
# 注册蓝图
app.register_blueprint(dashboard_bp)
app.register_blueprint(system_bp)
app.register_blueprint(media_bp)
app.register_blueprint(actions_bp)
@app.route("/")
def index():
return "<h1>SkitPanel Backend is running!</h1>"
with app.app_context():
init_scheduler()
return app
if __name__ == '__main__':
app = create_app()
# 生产环境应使用 Gunicorn 或 uWSGI
# debug=True 模式下,修改代码后服务会自动重启
app.run(host='0.0.0.0', port=5000, debug=True)