Files
weidian/server/app.py

36 lines
877 B
Python
Raw Normal View History

import os
import sys
# 确保项目根目录在 sys.path 中
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from flask import Flask, redirect, url_for
from server.database import init_db
from server.routers import accounts, tasks, orders
def create_app():
app = Flask(
__name__,
template_folder=os.path.join(os.path.dirname(__file__), '..', 'templates'),
static_folder=os.path.join(os.path.dirname(__file__), '..', 'static'),
)
app.secret_key = 'snatcher-secret-key-change-me'
init_db()
app.register_blueprint(accounts.bp)
app.register_blueprint(tasks.bp)
app.register_blueprint(orders.bp)
@app.route('/')
def index():
return redirect(url_for('tasks.list_tasks'))
return app
if __name__ == '__main__':
app = create_app()
app.run(host='0.0.0.0', port=9000, debug=True)