API: poetry upgrade
This commit is contained in:
		
							parent
							
								
									b0766933b0
								
							
						
					
					
						commit
						61ad59e90a
					
				
					 6 changed files with 820 additions and 633 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
from .app import app
 | 
			
		||||
 | 
			
		||||
__all__ = ["app"]
 | 
			
		||||
| 
						 | 
				
			
			@ -21,32 +21,26 @@ app = FastAPI(
 | 
			
		|||
    redoc_url=SETTINGS.redoc_url,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@app.on_event("startup")
 | 
			
		||||
async def add_middlewares() -> None:
 | 
			
		||||
    if SETTINGS.production_mode:
 | 
			
		||||
        # Mount frontend in production mode
 | 
			
		||||
        app.mount(
 | 
			
		||||
            path="/",
 | 
			
		||||
            app=StaticFiles(
 | 
			
		||||
                directory=SETTINGS.ui_directory,
 | 
			
		||||
                html=True,
 | 
			
		||||
            ),
 | 
			
		||||
            name="frontend",
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    else:
 | 
			
		||||
        # Allow CORS in debug mode
 | 
			
		||||
        app.add_middleware(
 | 
			
		||||
            CORSMiddleware,
 | 
			
		||||
            allow_origins=[
 | 
			
		||||
                "*",
 | 
			
		||||
            ],
 | 
			
		||||
            allow_credentials=True,
 | 
			
		||||
            allow_methods=["*"],
 | 
			
		||||
            allow_headers=["*"],
 | 
			
		||||
            expose_headers=["*"],
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
app.include_router(router)
 | 
			
		||||
 | 
			
		||||
if SETTINGS.production_mode:
 | 
			
		||||
    # Mount frontend in production mode
 | 
			
		||||
    app.mount(
 | 
			
		||||
        path="/",
 | 
			
		||||
        app=StaticFiles(
 | 
			
		||||
            directory=SETTINGS.ui_directory,
 | 
			
		||||
            html=True,
 | 
			
		||||
        ),
 | 
			
		||||
        name="frontend",
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
else:
 | 
			
		||||
    # Allow CORS in debug mode
 | 
			
		||||
    app.add_middleware(
 | 
			
		||||
        CORSMiddleware,
 | 
			
		||||
        allow_credentials=True,
 | 
			
		||||
        allow_origins=["*"],
 | 
			
		||||
        allow_methods=["*"],
 | 
			
		||||
        allow_headers=["*"],
 | 
			
		||||
        expose_headers=["*"],
 | 
			
		||||
    )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ def main() -> None:
 | 
			
		|||
    """
 | 
			
		||||
 | 
			
		||||
    uvicorn.run(
 | 
			
		||||
        app="advent22_api:app",
 | 
			
		||||
        app="advent22_api.app:app",
 | 
			
		||||
        host="0.0.0.0",
 | 
			
		||||
        port=8000,
 | 
			
		||||
        reload=not SETTINGS.production_mode,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
from pydantic import BaseModel, BaseSettings
 | 
			
		||||
from pydantic import BaseModel
 | 
			
		||||
from pydantic_settings import BaseSettings, SettingsConfigDict
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DavSettings(BaseModel):
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +31,12 @@ class Settings(BaseSettings):
 | 
			
		|||
    Per-run settings.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    model_config = SettingsConfigDict(
 | 
			
		||||
        env_file=".env",
 | 
			
		||||
        env_file_encoding="utf-8",
 | 
			
		||||
        env_nested_delimiter="__",
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    #####
 | 
			
		||||
    # general settings
 | 
			
		||||
    #####
 | 
			
		||||
| 
						 | 
				
			
			@ -54,10 +61,5 @@ class Settings(BaseSettings):
 | 
			
		|||
    cache_ttl: int = 30
 | 
			
		||||
    config_filename: str = "config.toml"
 | 
			
		||||
 | 
			
		||||
    class Config:
 | 
			
		||||
        env_file = ".env"
 | 
			
		||||
        env_file_encoding = "utf-8"
 | 
			
		||||
        env_nested_delimiter = "__"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
SETTINGS = Settings()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1367
									
								
								api/poetry.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1367
									
								
								api/poetry.lock
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -9,19 +9,18 @@ name = "advent22_api"
 | 
			
		|||
version = "0.1.0"
 | 
			
		||||
 | 
			
		||||
[tool.poetry.dependencies]
 | 
			
		||||
fastapi = "^0.85.0"
 | 
			
		||||
python = "^3.10"
 | 
			
		||||
uvicorn = {extras = ["standard"], version = "^0.18.3"}
 | 
			
		||||
Pillow = "^9.2.0"
 | 
			
		||||
numpy = "^1.23.3"
 | 
			
		||||
webdavclient3 = "3.14.5"
 | 
			
		||||
Pillow = "^10.0.0"
 | 
			
		||||
async-cache = "^1.1.1"
 | 
			
		||||
fastapi = "^0.103.1"
 | 
			
		||||
numpy = "^1.25.2"
 | 
			
		||||
python = "^3.11"
 | 
			
		||||
tomli = "^2.0.1"
 | 
			
		||||
 | 
			
		||||
[tool.poetry.dev-dependencies]
 | 
			
		||||
uvicorn = {extras = ["standard"], version = "^0.23.2"}
 | 
			
		||||
webdavclient3 = "^3.14.6"
 | 
			
		||||
pydantic-settings = "^2.0.3"
 | 
			
		||||
 | 
			
		||||
[tool.poetry.group.dev.dependencies]
 | 
			
		||||
flake8 = "^6.0.0"
 | 
			
		||||
flake8 = "^6.1.0"
 | 
			
		||||
 | 
			
		||||
[build-system]
 | 
			
		||||
build-backend = "poetry.core.masonry.api"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue