From f271f8ae364baf3f3b7feadf828c084c5210804e Mon Sep 17 00:00:00 2001 From: sporteka Date: Mon, 17 Aug 2026 08:25:16 +0300 Subject: [PATCH] fix: Werkzeug pin, .env.local path, spec description, random collection param - requirements.txt: pin Werkzeug to 2.2.3 (compatible with Flask 2.2.5); Werkzeug 3.x has no __version__ and breaks Flask's test client and serving internals - README.md: deployment section referred to 'env.local', but the file (and the rest of the README) is named .env.local - spec.v1.yml: /collections/.../chapters/{chapterId} path parameter was described as 'Number of the book'; it is the chapter ID - main.py: /v1/hadiths/random hardcoded collection='riyadussalihin' (had a TODO to make it configurable); accept a 'collection' query parameter, keeping riyadussalihin as the default --- README.md | 2 +- main.py | 4 ++-- requirements.txt | 2 +- spec.v1.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c229782..1352b6f 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ $ curl http://localhost:5000 ## Deployment -Configuration files are located at `env.local` and `uwsgi.ini`. +Configuration files are located at `.env.local` and `uwsgi.ini`. A production ready uWSGI daemon (uwsgi socket exposed on port 5001) can be started with: diff --git a/main.py b/main.py index 68281c6..cf847fc 100644 --- a/main.py +++ b/main.py @@ -275,8 +275,8 @@ def api_hadiths_by_refs(): @app.route("/v1/hadiths/random", methods=["GET"]) @single_resource def api_hadiths_random(): - # TODO Make this configurable instead of hardcoding - return Hadith.query.filter_by(collection="riyadussalihin").order_by(func.rand()) + collection = request.args.get("collection", "riyadussalihin") + return Hadith.query.filter_by(collection=collection).order_by(func.rand()) if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt index aafd2a5..557715a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,6 +32,6 @@ six==1.15.0 SQLAlchemy==1.3.17 toml==0.10.1 virtualenv==20.36.1 -Werkzeug==3.1.5 +Werkzeug==2.2.3 wrapt==1.12.1 zipp==3.15.0 diff --git a/spec.v1.yml b/spec.v1.yml index 4f49a8f..4aa7939 100644 --- a/spec.v1.yml +++ b/spec.v1.yml @@ -178,7 +178,7 @@ paths: type: string - in: path name: chapterId - description: Number of the book + description: ID of the chapter required: true schema: type: number