-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (34 loc) · 1.15 KB
/
app.py
File metadata and controls
45 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
from flask import Flask
from flask_migrate import Migrate
from extensions import db, login_manager, mail, scheduler, socketio
def create_app():
app = Flask(__name__)
# Configuration
app.config.from_object('config.Config')
# Initialize extensions
db.init_app(app)
# Store db instance in app config instead
app.config['db'] = db
# Initialize Flask-Migrate
migrate = Migrate(app, db)
login_manager.init_app(app)
login_manager.login_view = 'admin.login' # type: ignore
mail.init_app(app)
scheduler.init_app(app)
socketio.init_app(app, cors_allowed_origins="*")
with app.app_context():
# Register blueprints
from routes.public import public_bp
from routes.admin import admin_bp
app.register_blueprint(public_bp)
app.register_blueprint(admin_bp, url_prefix='/admin')
# Initialize database
from migrations import init_db
init_db()
# Start scheduler
from tasks import schedule_synthesis
scheduler.start()
schedule_synthesis()
return app
app = create_app()