Gagan0141 commited on
Commit
6aab815
·
verified ·
1 Parent(s): 311f21c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -2,6 +2,18 @@ from flask import Flask, render_template, request, redirect, url_for, session, f
2
  from flask_sqlalchemy import SQLAlchemy
3
  from werkzeug.security import generate_password_hash, check_password_hash
4
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  # Initialize Flask app
6
  app = Flask(__name__)
7
  app.secret_key = 'your_super_secret_key'
 
2
  from flask_sqlalchemy import SQLAlchemy
3
  from werkzeug.security import generate_password_hash, check_password_hash
4
 
5
+ import os
6
+
7
+ # Check if running on Hugging Face
8
+ if os.getenv("SPACE_ID"): # Hugging Face sets this env var
9
+ db_path = os.path.join("/tmp", "database.db")
10
+ else:
11
+ db_path = os.path.join(os.path.dirname(__file__), "database.db")
12
+
13
+ app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}"
14
+ app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
15
+
16
+
17
  # Initialize Flask app
18
  app = Flask(__name__)
19
  app.secret_key = 'your_super_secret_key'