Skip to content

Commit f685144

Browse files
Model Updates
1 parent e8be251 commit f685144

File tree

171 files changed

+12370
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+12370
-0
lines changed

README.md

__pycache__/config.cpython-39.pyc

589 Bytes
Binary file not shown.

__pycache__/run.cpython-310.pyc

1.22 KB
Binary file not shown.

__pycache__/run.cpython-311.pyc

1.9 KB
Binary file not shown.

__pycache__/run.cpython-313.pyc

1.75 KB
Binary file not shown.

__pycache__/run.cpython-39.pyc

1.12 KB
Binary file not shown.

app/__init__.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from flask import Flask
2+
from flask_sqlalchemy import SQLAlchemy
3+
from flask_migrate import Migrate # ✅ ADD THIS
4+
from dotenv import load_dotenv
5+
import os
6+
from flask_login import LoginManager
7+
from app.extensions import db
8+
from app.models.users import User
9+
from app.routes.model_routes import api_bp
10+
from app.routes.main_routes import main as main_routes
11+
from app.routes.api_routes import api as api_routes
12+
13+
# Create login manager and migrate globally
14+
login_manager = LoginManager()
15+
migrate = Migrate() # ✅ ADD THIS
16+
17+
def create_app():
18+
# Load environment variables
19+
load_dotenv()
20+
21+
# Create Flask app
22+
app = Flask(__name__)
23+
24+
# Configuration
25+
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'fallback-secret-key')
26+
app.config['SQLALCHEMY_DATABASE_URI'] = (
27+
f"postgresql://{os.getenv('DB_USER')}:{os.getenv('DB_PASSWORD')}@{os.getenv('DB_HOST')}/{os.getenv('DB_NAME')}"
28+
)
29+
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
30+
31+
# Initialize extensions
32+
db.init_app(app)
33+
migrate.init_app(app, db) # ✅ REGISTER FLASK-MIGRATE HERE
34+
login_manager.init_app(app)
35+
login_manager.login_view = 'main.login'
36+
37+
# User loader
38+
@login_manager.user_loader
39+
def load_user(user_id):
40+
return User.query.get(int(user_id))
41+
42+
# Register blueprints
43+
app.register_blueprint(main_routes)
44+
app.register_blueprint(api_routes)
45+
app.register_blueprint(api_bp, url_prefix='/api')
46+
47+
return app
1.44 KB
Binary file not shown.
1.59 KB
Binary file not shown.
2.05 KB
Binary file not shown.

0 commit comments

Comments
 (0)