Project Euler solutions.
Install dependencies:
python3 -m pip install -r requirements.txtRun the API:
uvicorn api:app --reloadRun it so other machines on your network can reach it:
.venv/bin/uvicorn api:app --host 0.0.0.0 --port 8000Run it with local HTTPS on port 8443 after placing certificates in ~/.config/euler-api/tls/:
.venv/bin/uvicorn api:app --host 0.0.0.0 --port 8443 \
--ssl-keyfile ~/.config/euler-api/tls/euler-local-server.key \
--ssl-certfile ~/.config/euler-api/tls/euler-local-server.crtFetch the code for a problem number:
curl http://127.0.0.1:8000/problems/8Optionally filter by language when multiple implementations exist:
curl "http://127.0.0.1:8000/problems/204?language=python"Install the service:
mkdir -p ~/.config/systemd/user
cp euler-api.service ~/.config/systemd/user/euler-api.service
systemctl --user daemon-reload
systemctl --user enable --now euler-api.serviceCheck status:
systemctl --user status euler-api.serviceFrom another machine on the same network, open:
http://<headless-machine-ip>:8000/docs
Before starting the HTTPS service, place these files in ~/.config/euler-api/tls/:
euler-local-server.key
euler-local-server.crt
euler-local-ca.crt
Install and start the HTTPS service:
mkdir -p ~/.config/systemd/user
cp euler-api-https.service ~/.config/systemd/user/euler-api-https.service
systemctl --user daemon-reload
systemctl --user enable --now euler-api-https.serviceThe service will listen on:
https://192.168.1.41:8443/
Trust the local CA on the GUI machine using this certificate:
~/.config/euler-api/tls/euler-local-ca.crt
Without trusting that CA, the browser will show a certificate warning.