Improve proxy

This commit is contained in:
Dominik Milacher 2025-06-14 12:08:54 +02:00
parent 26ec7ace9e
commit be9e3a7ee7
6 changed files with 14 additions and 8 deletions

View File

@ -0,0 +1,4 @@
# rename this to .env
BREVO_API_KEY=brevo_api_key
BREVO_SENDER=proxy@example.com

View File

@ -1 +1,2 @@
.env
hotels.db

View File

@ -1,3 +1,5 @@
# TODO bettter move everything to .env and gitignore it
INITIAL SETUP
cd email-proxy

View File

@ -1,11 +1,11 @@
services:
email-proxy:
restart: unless-stopped
build: .
ports:
- "8000:8000"
volumes:
- ./hotels.db:/app/hotels.db
environment:
- BREVO_API_KEY=<KEY>
- BREVO_SENDER=<proxy@example.com>
- BREVO_API_KEY=${BREVO_API_KEY}
- BREVO_SENDER=${BREVO_SENDER}
restart: unless-stopped

View File

@ -27,7 +27,7 @@ def on_startup():
# --- API Endpoints ---
@app.post("/api/contact")
@app.post("/contact")
async def contact(request: Request):
data = await request.json()
hotel_id = data.get("hotel")
@ -74,4 +74,3 @@ async def send_brevo_email(to_email, from_name, reply_to_email, subject, message
)
if r.status_code >= 400:
raise HTTPException(status_code=500, detail=f"Email failed: {r.text}")

View File

@ -12,15 +12,15 @@ command = sys.argv[1].lower()
if command == "add" and len(sys.argv) == 4:
# Run helper.py inside container with add
subprocess.run([
"docker-compose", "run", "--rm", "email-proxy",
"sudo", "docker", "compose", "run", "--rm", "email-proxy",
"python", "helper.py", "add", sys.argv[2], sys.argv[3]
])
elif command == "remove" and len(sys.argv) == 3:
# Run helper.py inside container with remove
subprocess.run([
"docker-compose", "run", "--rm", "email-proxy",
"sudo", "docker", "compose", "run", "--rm", "email-proxy",
"python", "helper.py", "remove", sys.argv[2]
])
else:
print("Invalid arguments.")
sys.exit(1)
sys.exit(1)