PyConES24/src/retailtwin/api
2024-05-08 21:55:08 +00:00
..
static Adding all files 2024-05-08 21:55:08 +00:00
__init__.py Adding all files 2024-05-08 21:55:08 +00:00
composition.py Adding all files 2024-05-08 21:55:08 +00:00
db.py Adding all files 2024-05-08 21:55:08 +00:00
main.py Adding all files 2024-05-08 21:55:08 +00:00
README.md Adding all files 2024-05-08 21:55:08 +00:00
settings.py Adding all files 2024-05-08 21:55:08 +00:00

Super simple API-based stock terminal

Run the backend with

DB_URI=postgresql+asyncpg://user:password@server/dbname uvicorn retailtwin.api.main:app

Use Caddy to reverse proxy and the following Caddyfile. Paths are static so you have to run caddy from the root of the package

:80 {
    handle_path /api/v1/* {
        reverse_proxy localhost:8000
    }
    file_server {
        root src/retailtwin/api/static
    }
}

If you execute

caddy run -c Caddyfile

You should be able to browse the application at http://127.0.0.1, and reach the api docs at http://127.0.0.1/api/v1/docs

Caddy can be installed in with Chocolatey on Windows, and with Homebrew on mac.