fix: set utf-8 encoding for config

This commit is contained in:
Данил 2025-02-20 21:50:06 +03:00
parent 4f70c6c0e3
commit 52d85edd41
2 changed files with 4 additions and 4 deletions

View file

@ -22,7 +22,7 @@ from starlette.responses import FileResponse
from src.middleware.plausible_analytics import PlausibleAnalytics
from src.routes import index, wallpaper
config = yaml.safe_load(open('config.yaml'))
config = yaml.safe_load(open('config.yaml', encoding='utf-8'))
app = FastAPI()

View file

@ -17,14 +17,14 @@ import yaml
import httpx
from user_agents import parse as ua_parse
config = yaml.safe_load(open('./config.yaml'))
config = yaml.safe_load(open('./config.yaml', encoding='utf-8'))
class PlausibleAnalytics:
"""
Middleware for sending analytics data to Plausible Analytics
after processing each request.
"""
async def __call__(self, request, call_next):
"""
Called for each request, sends an event to Plausible with
@ -37,7 +37,7 @@ class PlausibleAnalytics:
Returns:
Response: FastAPI response object.
"""
response = await call_next(request)
user_agent = request.headers.get('user-agent', 'unknown')