Spaces:
Sleeping
Sleeping
| """Hugging Face Spaces entry point — runs the Flask app on port 7860.""" | |
| import os | |
| os.environ.setdefault("FLASK_APP", "app") | |
| os.environ.setdefault("FLASK_ENV", "production") | |
| os.environ.setdefault("SQLALCHEMY_DATABASE_URI", "sqlite:////app/liver_disease.db") | |
| os.environ.setdefault("SECRET_KEY", "hf-space-secret-change-in-production") | |
| os.environ.setdefault("SKIP_ARTIFACT_CHECK", "true") | |
| from app import create_app | |
| from app.extensions import db, bcrypt | |
| from app.models.user import User | |
| application = create_app("production") | |
| # Initialise DB and seed admin on first start | |
| with application.app_context(): | |
| db.create_all() | |
| if not db.session.query(User).filter_by(username="admin").first(): | |
| hashed = bcrypt.generate_password_hash("Admin@1234").decode("utf-8") | |
| db.session.add(User( | |
| username="admin", | |
| password=hashed, | |
| role="admin", | |
| status="active", | |
| failed_logins=0, | |
| )) | |
| db.session.commit() | |
| if __name__ == "__main__": | |
| application.run(debug=False, host="0.0.0.0", port=7860) | |