9fe3196827
All sims re-run after pipeline fixes (better prompts, real syntax validation, fenced-block extraction fix). Results: 7/7 PASS, 20 files total, all Python files pass compile() syntax check. Includes run_all_sims.py runner script and rag-basic action config.
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from flask import Flask
|
|
from models import db, User
|
|
import os
|
|
|
|
def create_app_context(app):
|
|
"""Create application context and initialize database."""
|
|
with app.app_context():
|
|
db.create_all()
|
|
return app
|
|
|
|
def init_database(app):
|
|
"""Initialize database with Flask app."""
|
|
db.init_app(app)
|
|
|
|
# Create tables if they don't exist
|
|
with app.app_context():
|
|
db.create_all()
|
|
|
|
# Create default admin user if it doesn't exist
|
|
admin_user = User.query.filter_by(username='admin').first()
|
|
if not admin_user and os.environ.get('CREATE_ADMIN_USER', 'false').lower() == 'true':
|
|
admin_email = os.environ.get('ADMIN_EMAIL', 'admin@example.com')
|
|
admin_password = os.environ.get('ADMIN_PASSWORD', 'admin123')
|
|
|
|
admin = User(
|
|
username='admin',
|
|
email=admin_email,
|
|
password=admin_password
|
|
)
|
|
db.session.add(admin)
|
|
db.session.commit()
|
|
print("Admin user created successfully")
|
|
|
|
def get_db():
|
|
"""Get database instance."""
|
|
return db |