Compare commits

...

3 Commits

3 changed files with 33 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
data

View File

@@ -1,18 +1,21 @@
# app/main.py
from fastapi import FastAPI, Request from fastapi import FastAPI, Request
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
import json import json
app = FastAPI() app = FastAPI()
DATA_FILE = Path("data.json")
DATA_DIR = Path("data")
DATA_FILE = DATA_DIR / "data.json"
# Ensure the data directory exists
DATA_DIR.mkdir(exist_ok=True)
@app.post("/submit") @app.post("/submit")
async def submit_data(request: Request): async def submit_data(request: Request):
payload = await request.json() payload = await request.json()
# Create the file if it doesn't exist # Initialize data file if it doesn't exist
if not DATA_FILE.exists(): if not DATA_FILE.exists():
with open(DATA_FILE, "w") as f: with open(DATA_FILE, "w") as f:
json.dump([], f) json.dump([], f)
@@ -27,3 +30,4 @@ async def submit_data(request: Request):
json.dump(existing_data, f, indent=4) json.dump(existing_data, f, indent=4)
return {"message": "Data saved successfully"} return {"message": "Data saved successfully"}

25
docker-compose.yml Normal file
View File

@@ -0,0 +1,25 @@
services:
storandom:
image: docker.io/moanos/storandom
container_name: "storandom"
restart: unless-stopped
environment:
# Note: those envs are customizable but also optional
- SERVER_PORT=8000
volumes:
- ./data:/app/data
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.storandom.rule=Host(`storandom.hyteck.de`)"
- "traefik.http.routers.storandom.service=storandom-service"
- "traefik.http.routers.storandom.entrypoints=web-secure"
- "traefik.http.routers.storandom.tls=true"
- "traefik.http.routers.storandom.tls.certResolver=default"
- "traefik.http.services.storandom-service.loadbalancer.server.port=8000"
networks:
- traefik
networks:
traefik:
name: "traefik"
external: true