Spaces:
Paused
Paused
Commit
·
da815dd
1
Parent(s):
d8d1294
app.py updated
Browse files
app.py
CHANGED
@@ -33,7 +33,25 @@ app = Flask(
|
|
33 |
template_folder='backend/templates'
|
34 |
)
|
35 |
app.config['SECRET_KEY'] = 'your-secret-key'
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
38 |
from flask_wtf.csrf import CSRFProtect
|
39 |
|
|
|
33 |
template_folder='backend/templates'
|
34 |
)
|
35 |
app.config['SECRET_KEY'] = 'your-secret-key'
|
36 |
+
#
|
37 |
+
# Configure the database connection
|
38 |
+
#
|
39 |
+
# By default the application wrote its SQLite database into the
|
40 |
+
# `/tmp` directory. On local machines this works, but on hosted
|
41 |
+
# platforms like Hugging Face Spaces the `/tmp` directory is not
|
42 |
+
# persistent across sessions. That means any data stored in
|
43 |
+
# `/tmp/codingo.db` would be lost once the process restarts, and
|
44 |
+
# newly created user accounts would appear to disappear immediately.
|
45 |
+
#
|
46 |
+
# To fix this we store the database file inside the project under
|
47 |
+
# `backend/instance/codingo.db`. The `backend/instance` directory
|
48 |
+
# already exists (it is created by `os.makedirs` below) and is
|
49 |
+
# persisted across requests, so user registrations and other data
|
50 |
+
# remain available. SQLAlchemy requires three slashes for a relative
|
51 |
+
# SQLite URI (e.g. `sqlite:///relative/path.db`). Here we use four
|
52 |
+
# leading slashes because the path is relative to the project
|
53 |
+
# directory when using `sqlite:///backend/instance/codingo.db`.
|
54 |
+
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///backend/instance/codingo.db'
|
55 |
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
56 |
from flask_wtf.csrf import CSRFProtect
|
57 |
|