Improve proxy
This commit is contained in:
parent
26ec7ace9e
commit
be9e3a7ee7
4
email-proxy/.env-template
Normal file
4
email-proxy/.env-template
Normal file
@ -0,0 +1,4 @@
|
||||
# rename this to .env
|
||||
|
||||
BREVO_API_KEY=brevo_api_key
|
||||
BREVO_SENDER=proxy@example.com
|
||||
1
email-proxy/.gitignore
vendored
1
email-proxy/.gitignore
vendored
@ -1 +1,2 @@
|
||||
.env
|
||||
hotels.db
|
||||
@ -1,3 +1,5 @@
|
||||
# TODO bettter move everything to .env and gitignore it
|
||||
|
||||
INITIAL SETUP
|
||||
|
||||
cd email-proxy
|
||||
|
||||
@ -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
|
||||
@ -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}")
|
||||
|
||||
|
||||
@ -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)
|
||||
Loading…
x
Reference in New Issue
Block a user