Download app.py from ed29/xertify: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/ed29/xertify/resolve/main/app.py
- Command line
-
hf download hf://spaces/ed29/xertify/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ed29/xertify/resolve/main/app.py
1.38 kB
| from flask import Flask, render_template, redirect, url_for | |
| from jinja2 import ChoiceLoader, FileSystemLoader | |
| from flask_login import LoginManager | |
| from app_pkg.models import db | |
| from app_pkg.routes import register_blueprints | |
| # Application Factory | |
| def create_app(): | |
| # Allow templates to be loaded from both `app/templates` and `app_pkg/templates`. | |
| app = Flask(__name__, template_folder="app_pkg/templates", static_folder="app_pkg/static") | |
| # Prefer `app/templates` first (developer edits often there), then `app_pkg/templates`. | |
| app.jinja_loader = ChoiceLoader([ | |
| FileSystemLoader("app/templates"), | |
| FileSystemLoader("app_pkg/templates"), | |
| ]) | |
| app.config.from_object("config.Config") | |
| db.init_app(app) | |
| login = LoginManager() | |
| login.login_view = "auth.login" | |
| login.init_app(app) | |
| from app_pkg.models.user import User | |
| def load_user(user_id): | |
| return User.query.get(int(user_id)) | |
| def index(): | |
| # Redirect root to the diplomas list; if user is not logged-in | |
| # the `list_diplomas` route is protected and will redirect to login. | |
| return redirect(url_for('diploma.list_diplomas')) | |
| register_blueprints(app) | |
| with app.app_context(): | |
| db.create_all() | |
| return app | |
| app = create_app() | |
| if __name__ == "__main__": | |
| app.run(debug=True) | |