UI REST API: accounts, bearer auth, API apps, sessions, OpenAPI docs
- flask-smorest API under /api/v1 with a uniform JSON error shape; spec at /api/openapi.json, Swagger UI at /api/docs, ReDoc at /api/redoc - Register/login/logout/me with hashed, expiring bearer tokens, documented as an OpenAPI bearer security scheme - API application and client-session management endpoints - CORS restricted to the configured UI origin(s) - Flask no longer serves static files: it is API-only - Login and registration metrics Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9af8a4be8b
commit
e026e56ee3
13 files changed
+626
-1
No files matched your search
@@ -11,16 +11,26 @@ def create_app(config_object=None):
|
||||
from scrobbler.extensions import db, migrate
|
||||
from scrobbler.metrics import http as http_metrics
|
||||
|
||||
app = Flask(__name__)
|
||||
app = Flask(__name__, static_folder=None) # API only: the UI is hosted separately
|
||||
app.config.from_object(config_object or Config)
|
||||
|
||||
db.init_app(app)
|
||||
migrate.init_app(app, db, directory=_migrations_dir())
|
||||
http_metrics.init_app(app)
|
||||
|
||||
from flask_cors import CORS
|
||||
|
||||
from scrobbler import api
|
||||
from scrobbler.lastfm import bp as lastfm_bp
|
||||
|
||||
app.register_blueprint(lastfm_bp)
|
||||
api.init_app(app)
|
||||
CORS(
|
||||
app,
|
||||
resources={r"/api/v1/*": {"origins": app.config["CORS_ORIGINS"]}},
|
||||
allow_headers=["Authorization", "Content-Type"],
|
||||
max_age=600,
|
||||
)
|
||||
|
||||
if app.config["START_METRICS_SERVER"]:
|
||||
from scrobbler.metrics.server import start_metrics_server
|
||||
|
||||
Reference in new issue
Block a user