-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.py
More file actions
59 lines (49 loc) · 1.77 KB
/
app.py
File metadata and controls
59 lines (49 loc) · 1.77 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from flask import Flask
from flask_migrate import Migrate
from extensions import db, migrate
from dotenv import load_dotenv
import os
import secrets
import logging
from routes import init_socketio
# Configure logging
logging.basicConfig(level=logging.INFO)
def create_app():
app = Flask(__name__)
# Load environment variables
load_dotenv()
# Configure app
app.config['SECRET_KEY'] = os.getenv('FLASK_SECRET_KEY', secrets.token_hex(16))
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///calendar.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['UPLOAD_FOLDER'] = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static', 'uploads')
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max file size
# Initialize extensions
db.init_app(app)
migrate.init_app(app, db)
socketio = init_socketio(app)
# Register blueprints
from routes import (
main_routes,
auth_routes,
calendar_routes,
message_routes,
resource_routes,
study_routes,
notification_routes,
class_routes
)
app.register_blueprint(main_routes, url_prefix='/')
app.register_blueprint(auth_routes, url_prefix='/auth')
app.register_blueprint(calendar_routes, url_prefix='/calendar')
app.register_blueprint(message_routes, url_prefix='/messages')
app.register_blueprint(resource_routes, url_prefix='/resources')
app.register_blueprint(study_routes, url_prefix='/study')
app.register_blueprint(notification_routes)
app.register_blueprint(class_routes, url_prefix='/classes')
return app
# Create the application instance
app = create_app()
# Main entry point of the application
if __name__ == '__main__':
socketio.run(app, debug=True)