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.
 
 

42 lines
905 B

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pydantic_settings import BaseSettings
from pydantic import BaseModel
import os
class UvicornSettings(BaseModel):
host: str = "0.0.0.0"
port: int = 8000
reload: bool = True
class Settings(BaseSettings):
DATABASE_URL: str
uvicorn: UvicornSettings = UvicornSettings()
class Config:
env_nested_delimiter = '__'
settings = Settings(_env_file=os.getenv("ENV", ".env"))
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def get_greeting():
return "hello"
if __name__ == "__main__":
import uvicorn
uvicorn.run(
app,
host = settings.uvicorn.host,
port = settings.uvicorn.port,
reload= settings.uvicorn.reload
)