Spaces:
Sleeping
Sleeping
Commit ·
da815dd
1
Parent(s): d8d1294
app.py updated
Browse files32 unmodified lines333435363738394041424344454647484950515253365455565732 unmodified lines template_folder='backend/templates')app.config['SECRET_KEY'] = 'your-secret-key'## Configure the database connection## By default the application wrote its SQLite database into the# `/tmp` directory. On local machines this works, but on hosted# platforms like Hugging Face Spaces the `/tmp` directory is not# persistent across sessions. That means any data stored in# `/tmp/codingo.db` would be lost once the process restarts, and# newly created user accounts would appear to disappear immediately.## To fix this we store the database file inside the project under# `backend/instance/codingo.db`. The `backend/instance` directory# already exists (it is created by `os.makedirs` below) and is# persisted across requests, so user registrations and other data# remain available. SQLAlchemy requires three slashes for a relative# SQLite URI (e.g. `sqlite:///relative/path.db`). Here we use four# leading slashes because the path is relative to the project# directory when using `sqlite:///backend/instance/codingo.db`.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/codingo.db'app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///backend/instance/codingo.db'app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = Falsefrom flask_wtf.csrf import CSRFProtect
app.py+19-1