30 lines
765 B
Python
30 lines
765 B
Python
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=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,
|
|
host=listen_ip,
|
|
port=listen_port
|
|
)
|