From 11522ac19beacbd65b94a77d539610580a368a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Wed, 21 Sep 2022 20:34:51 +0000 Subject: [PATCH] API readme --- api/README.md | 38 +++++++++++++++++++++++++++++++-- api/ovdashboard_api/__main__.py | 4 +++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/api/README.md b/api/README.md index 38b06e2..88e7aa8 100644 --- a/api/README.md +++ b/api/README.md @@ -2,8 +2,42 @@ This API enables the OVDashboard UI to run. + ## Quick Start -Preferably, use the `docker` image at `TODO` to run API and UI simultaneously. Refer to the [main config](TODO) for how to do that. +Preferably, use the `docker` image at `TODO` to run this API and its UI simultaneously. Refer to the [main README](../README.md) for how to do that. -## Running the API \ No newline at end of file + +## Running the API without a container + +Install the `ovdashboard_api` python package, you can: + +- use `uvicorn` or another ASGI runner to start the app object `ovdashboard_api:app`
+Example: `uvicorn 'ovdashboard_api:app'` +- run the provided `ovdashboard-api` script – this is basically a shorthand for `uvicorn` +- use `gunicorn` or another application server with ASGI workers (can be provided by `uvicorn`)
+Example: `gunicorn 'ovdashboard_api:app' --worker-class uvicorn.workers.UvicornWorker` + + +## Configuration + +The OVDashboard API is fully configured by environment variables or an `.env` file in the current working directory. Refer to the [main README](../README.md) for the list of variables. + + +## Dependencies + +Refer to your distribution's manual for how to install these dependencies. + +- Python 3.9 with pip
+If `python3 --version` shows "Python 3.9" or later, and `python3 -m pip` does execute, you're good to go +- git (recommended) +- libmagic + + +## Installation + +If `git` is installed, install `ovdashboard_api` directly using this command: + + python3 -m pip install 'git+https://TODO#egg=ovdashboard_api&subdirectory=api' + +If installing `git` is not an option, just [download and extract this repository's archive](TODO), then use the local path instead of the `git+https` URL for `pip install`. diff --git a/api/ovdashboard_api/__main__.py b/api/ovdashboard_api/__main__.py index 0cb503d..68ad6bf 100644 --- a/api/ovdashboard_api/__main__.py +++ b/api/ovdashboard_api/__main__.py @@ -1,5 +1,7 @@ from uvicorn import run as uvicorn_run +from .settings import SETTINGS + def main() -> None: """ @@ -10,7 +12,7 @@ def main() -> None: app="ovdashboard_api:app", host="0.0.0.0", port=8000, - reload=True, + reload=not SETTINGS.production_mode, )