Fix Flask app initialization to determine project root before creating app

parent c2d090ce
......@@ -35,12 +35,16 @@ from .admin import admin_bp
from .utils import get_current_user_session, login_required, admin_required
# Determine project root (parent of vidai directory)
project_root = os.path.dirname(app.root_path)
current_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(current_dir)
app = Flask(__name__,
template_folder=os.path.join(project_root, 'templates'),
static_folder=os.path.join(project_root, 'static'))
app.secret_key = os.environ.get('FLASK_SECRET_KEY', 'dev-secret-key-change-in-production')
os.makedirs('../static', exist_ok=True)
# Ensure static directory exists
os.makedirs(os.path.join(project_root, 'static'), exist_ok=True)
# Ensure avatars directory exists
avatars_dir = os.path.join(project_root, 'static', 'avatars')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment