Skip to content

Commit

Permalink
Remove fastapi-localization (#132)
Browse files Browse the repository at this point in the history
<!--- Please write your PR name in the present imperative tense.
Examples of that tense are: "Fix issue in the dispatcher where…",
"Improve our handling of…", etc." -->
<!-- For more information on Pull Requests, you can reference here:
https://success.vanillaforums.com/kb/articles/228-using-pull-requests-to-contribute
-->
## Describe Your Changes

Removed fastapi-localization and related code we are not using.

## Non-Obvious Technical Information


## Checklist Before Requesting a Review
- [x] The code runs successfully.

```commandline
2024-01-04 13:35:20 INFO:     Will watch for changes in these directories: ['/usr/src/app']
2024-01-04 13:35:20 INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
2024-01-04 13:35:20 INFO:     Started reloader process [1] using WatchFiles
2024-01-04 13:35:22 DEBUG:      Routers loaded and static files mounted.
2024-01-04 13:35:22 INFO:     Started server process [8]
2024-01-04 13:35:22 INFO:     Waiting for application startup.
2024-01-04 13:35:22 INFO:     Application startup complete.
2024-01-04 13:35:41 INFO:     172.25.0.1:59156 - "GET / HTTP/1.1" 200 OK
2024-01-04 13:35:43 INFO:     172.25.0.1:47710 - "GET /admin/login HTTP/1.1" 200 OK
. . .
2024-01-04 13:35:52 INFO:     172.25.0.1:47312 - "POST /admin/login HTTP/1.1" 302 Found
2024-01-04 13:35:52 INFO:     172.25.0.1:47310 - "GET /admin/dashboard HTTP/1.1" 200 OK
2024-01-04 13:35:57 INFO:     172.25.0.1:47310 - "GET /games/session/6 HTTP/1.1" 200 OK
2024-01-04 13:35:59 INFO:     172.25.0.1:47310 - "GET /games/15/player/88/ready HTTP/1.1" 200 OK
2024-01-04 13:36:01 INFO:     172.25.0.1:47310 - "GET /games/15/player/88/survey HTTP/1.1" 200 OK

```
  • Loading branch information
anisfeld authored Jan 4, 2024
1 parent 8fe19e5 commit 74ac9a9
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 60 deletions.
16 changes: 1 addition & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions prijateli_tree/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
KEY_ENV_DEV,
KEY_ENV_PROD,
KEY_ENV_TESTING,
LANGUAGE_ENGLISH,
)


Expand All @@ -16,7 +15,6 @@ class BaseConfig:
def __init__(self):
# App Settings
self.DEBUG = False
self.LANGUAGE = LANGUAGE_ENGLISH
self.LOGGING_FORMAT = "%(levelname)s:\t%(message)s"
self.LOG_LEVEL = logging.DEBUG
self.TESTING = False
Expand Down
44 changes: 3 additions & 41 deletions prijateli_tree/app/main.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import logging
import os
from pathlib import Path
from typing import Annotated

from fastapi import FastAPI, Header, Request, Response
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi import FastAPI, Request, Response
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from fastapi_localization import TranslateJsonResponse

from prijateli_tree.app.config import config
from prijateli_tree.app.routers import administration, games
from prijateli_tree.app.utils.constants import (
KEY_ENV,
LANGUAGE_ALBANIAN,
LANGUAGE_ENGLISH,
LANGUAGE_MACEDONIAN,
LANGUAGE_TURKISH,
)
from prijateli_tree.app.utils.constants import KEY_ENV


config = config[os.getenv(KEY_ENV)]
Expand Down Expand Up @@ -48,36 +40,6 @@
logger.debug("Routers loaded and static files mounted.")


@app.post(
"/language",
response_class=TranslateJsonResponse,
)
def set_language(
accept_language: Annotated[str | None, Header()] = None
) -> JSONResponse:
if accept_language in [
LANGUAGE_ENGLISH,
LANGUAGE_TURKISH,
LANGUAGE_MACEDONIAN,
LANGUAGE_ALBANIAN,
]:
config.LANGUAGE = accept_language
else:
config.LANGUAGE = LANGUAGE_ENGLISH

return JSONResponse(content={"message": "It done worked"})


@app.get("/", response_class=HTMLResponse)
def home(request: Request) -> Response:
return templates.TemplateResponse("home_page.html", {"request": request})


@app.get("/ready", response_class=HTMLResponse)
def ready(request: Request) -> Response:
return templates.TemplateResponse("ready.html", {"request": request})


@app.get("/waiting", response_class=HTMLResponse)
def waiting(request: Request) -> Response:
return templates.TemplateResponse("waiting.html", {"request": request})
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ fastapi-sqlalchemy = "^0.2.1"
psycopg2 = "^2.9.9"
python-dotenv = "^1.0.0"
pyi18n-v2 = "^1.2.1"
fastapi-localization = "^0.0a2.dev3"
jinja2 = "^3.1.2"
python-multipart = "^0.0.6"
pytest = "^7.4.3"
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ charset-normalizer==3.3.2 ; python_version >= "3.11" and python_version < "4.0"
click==8.1.7 ; python_version >= "3.11" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.11" and python_version < "4.0" and (sys_platform == "win32" or platform_system == "Windows")
et-xmlfile==1.1.0 ; python_version >= "3.11" and python_version < "4.0"
fastapi-localization==0.0a2.dev3 ; python_version >= "3.11" and python_version < "4.0"
fastapi-login==1.9.2 ; python_version >= "3.11" and python_version < "4.0"
fastapi-sqlalchemy==0.2.1 ; python_version >= "3.11" and python_version < "4.0"
fastapi==0.103.2 ; python_version >= "3.11" and python_version < "4.0"
Expand Down

0 comments on commit 74ac9a9

Please sign in to comment.