-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
33 lines (27 loc) · 874 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# server.py
import os
from waitress import serve
from app import app # Import your Flask app
if __name__ == '__main__':
# Configure host and port
host = os.getenv("SERVER_HOST", "0.0.0.0")
port = int(os.getenv("SERVER_PORT", 8080))
print(f"Starting Waitress server on {host}:{port}...")
print(f"Open: http://127.0.0.1:{port}")
serve(app, host=host, port=port, threads=4) # Adjust threads based on needs
# Optional production config
from app import app
import logging
# Configure logging
logging.basicConfig(
filename='production.log',
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# Set Flask configs for production
app.config.update(
SESSION_COOKIE_SECURE=True,
SESSION_COOKIE_HTTPONLY=True,
SESSION_COOKIE_SAMESITE='Lax',
PERMANENT_SESSION_LIFETIME=1800 # 30 minutes
)