added loading of defaults
This commit is contained in:
+14
-2
@@ -1,14 +1,26 @@
|
||||
import uvicorn
|
||||
from setup_logging import setup_logging
|
||||
from dotenv import load_dotenv
|
||||
from app import app
|
||||
import logging
|
||||
import os
|
||||
from configparser import ConfigParser
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# load default values
|
||||
config = ConfigParser()
|
||||
config.read(Path(__file__).parent / 'defaults.ini')
|
||||
LISTEN_IP = config.get('fastapi', 'listen_ip')
|
||||
LISTEN_PORT = int(config.get('fastapi', 'listen_port'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# setup
|
||||
load_dotenv()
|
||||
setup_logging()
|
||||
listen_ip = os.getenv('LISTEN_IP', default='0.0.0.0')
|
||||
listen_port = int(os.getenv('LISTEN_PORT', default=8000))
|
||||
listen_ip = os.getenv('LISTEN_IP', default=LISTEN_IP)
|
||||
listen_port = int(os.getenv('LISTEN_PORT', default=LISTEN_PORT))
|
||||
logging.info(f'starting FastAPI server ({listen_ip}:{listen_port})')
|
||||
uvicorn.run(
|
||||
app=app,
|
||||
|
||||
Reference in New Issue
Block a user