Skip to content

Commit

Permalink
fix: add image serving
Browse files Browse the repository at this point in the history
We need to allow users to fetch images they uploaded
  • Loading branch information
raphael0202 committed Nov 23, 2023
1 parent 1b0667d commit 5808b7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
from fastapi.responses import HTMLResponse, PlainTextResponse
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from fastapi_filter import FilterDepends
from fastapi_pagination import Page, add_pagination
Expand Down Expand Up @@ -253,3 +254,4 @@ def robots_txt():


add_pagination(app)
app.mount("/images", StaticFiles(directory=str(settings.images_dir)), name="images")
3 changes: 2 additions & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pydantic_settings import BaseSettings, SettingsConfigDict

ROOT_DIR = Path(__file__).parent.parent
DATA_DIR = ROOT_DIR / "data"


class LoggingLevel(Enum):
Expand Down Expand Up @@ -38,7 +39,7 @@ class Settings(BaseSettings):
oauth2_server_url: str | None = None
sentry_dns: str | None = None
log_level: LoggingLevel = LoggingLevel.INFO
images_dir: Path = ROOT_DIR / "data/images"
images_dir: Path = DATA_DIR / "images"

model_config = SettingsConfigDict(env_file=".env", extra="ignore")

Expand Down

0 comments on commit 5808b7a

Please sign in to comment.