Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@ Use the built-in FastAPI server for local testing:
```bash
cd ~/hs.rest-api
source venv/bin/activate
uvicorn main:app --reload --host 127.0.0.1 --port 8000
hypercorn main:app --reload --bind 127.0.0.1:8000
```

If you want the server accessible externally in a test environment via `xyz00.hostsharing.net`, set the host to `0.0.0.0`. Example:
```bash
uvicorn main:app --reload --host 0.0.0.0 --port 8000
hypercorn main:app --reload --bind 0.0.0.0:8000
```
> **Warning:** Do not use the built-in server in production!

### Container

Podman/Docker
Expand All @@ -90,13 +88,13 @@ podman run -d \
-p 8000:8000 \
-v /path/to/env.yaml:/app/env.yaml:ro \
--name hs-rest-api \
docker pull ghcr.io/openadministration/hs.rest-api:v.xy
ghcr.io/openadministration/hs.rest-api:v.xy
```
Or docker-compose.yml:
```yaml
services:
hs-rest-api:
image: docker pull ghcr.io/openadministration/hs.rest-api:v.xy
image: ghcr.io/openadministration/hs.rest-api:v.xy
ports:
- "8000:8000"
volumes:
Expand Down
3 changes: 2 additions & 1 deletion env.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ api:
server:
host: 127.0.0.1
port: 8000
# Log level for both uvicorn access logs and application logs.
# Log level for both access logs and application logs.
# critical
# error — XML-RPC faults and unexpected exceptions only
# warning — + unknown API keys
# info — + every XML-RPC call with PAC name (recommended for production)
Expand Down
2 changes: 1 addition & 1 deletion hs-rest-api.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=hs.rest-api Uvicorn Service
Description=hs.rest-api Service
After=network.target

[Service]
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ pyyaml
python-dotenv~=1.1.1
fastapi>=0.116.1,<0.117.0
pydantic~=2.11.7
uvicorn[standard]
hypercorn
python-multipart
starlette~=0.47.3
cachetools~=6.2.0
gunicorn
cachetools~=6.2.0
4 changes: 2 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uvicorn
import subprocess
import yaml

with open("env.yaml", "r") as file:
Expand All @@ -8,4 +8,4 @@
log = env["log-level"]
worker = env["worker"]
if __name__ == "__main__":
uvicorn.run("main:app", host=host, port=port, log_level=log, workers=4)
subprocess.run(["hypercorn", "main:app", "--bind", f"{host}:{port}", "--log-level", log, "--workers",str(worker)])
Loading