You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
787 B
28 lines
787 B
#!/usr/bin/env python3 |
|
# -*- coding: utf-8 -*- |
|
"""Точка входа: dev — встроенный сервер Flask, prod — waitress.""" |
|
import os |
|
|
|
from dotenv import load_dotenv |
|
|
|
load_dotenv(os.path.join(os.path.dirname(__file__), '.env')) |
|
|
|
from app import create_app |
|
|
|
app = create_app() |
|
|
|
def _use_waitress() -> bool: |
|
if os.environ.get('FLASK_ENV') == 'production': |
|
return True |
|
v = (os.environ.get('WEB_USE_WAITRESS') or '').strip().lower() |
|
return v in ('1', 'true', 'yes', 'on') |
|
|
|
|
|
if __name__ == '__main__': |
|
port = int(os.environ.get('PORT', '3108')) |
|
if _use_waitress(): |
|
from waitress import serve |
|
|
|
serve(app, host='0.0.0.0', port=port) |
|
else: |
|
app.run(host='0.0.0.0', port=port, debug=os.environ.get('FLASK_DEBUG') == '1')
|
|
|