From 16ccad9cbf628689f0a290dc06e11e83edf69d80 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Fri, 18 Oct 2024 10:35:34 -0400 Subject: [PATCH] feat: add run-web-api.sh to easy launch dev mode API server --- README.md | 6 ++++++ run-web-api.sh | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 run-web-api.sh diff --git a/README.md b/README.md index 15f7b4cf..0e8dea85 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,12 @@ For information on spinning up your own dev Web API server locally, have a look DEVELOPMENT=1 uvicorn readalongs.web_api:web_api_app --reload +or + + ./run-web-api.sh + +Note that the production command line for the Web API is defined in `Procfile` and documented in [web\_api.py](readalongs/web_api.py). + #### /langs To query a list of available languages in the ReadAlong Studio API, send a GET request to https://readalongs-studio.herokuapp.com/api/v1/langs diff --git a/run-web-api.sh b/run-web-api.sh new file mode 100755 index 00000000..54abc174 --- /dev/null +++ b/run-web-api.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Convenience script to launch the Web API in development mode. +# Do not use in production! (See ../Procfile for the prod launch command.) +# +# Usage: +# pip install uvicorn +# /path/to/run-web-api.sh +# +# Further documentation is in readalongs/web_api.py + +# Move to the code root directory, so that --reload works correctly. +CODE_ROOT_PATH=$(dirname $(realpath $0))/readalongs +cd $CODE_ROOT_PATH + +# Launch the Web API with the --reload option, which will automatically reload +# the server whenver the code changes. +DEVELOPMENT=1 uvicorn readalongs.web_api:web_api_app --reload