Skip to content
Snippets Groups Projects

Resolve "Bild wird nicht angezeigt"

Merged Michelle Weidling requested to merge 36-bild-wird-nicht-angezeigt into develop
+ 8
10
import logging
import json
import xml.etree.ElementTree as ET
from os.path import exists
from os.path import exists, isfile
from pathlib import Path
from fastapi import FastAPI, Request, Response
from fastapi.middleware.cors import CORSMiddleware
@@ -79,21 +79,19 @@ async def get_css(file_name: str):
return FileResponse(css_path)
logging.warning(f'Requested file {file_name}.css not available.')
@app.get('/api/eupt/img/{file_name}', response_class=HTMLResponse)
async def get_img(file_name: str, request: Request):
@app.get('/api/eupt/img/{file_name}')
async def get_img(file_name: str):
"""
Returns an image file.
Args:
- file_name: The name of the file w/o extension
"""
img_path = Path(f'assets/img/{file_name}.svg')
if exists(img_path):
with open(img_path, mode='r', encoding='utf-8') as img_file:
result = img_file.read()
else:
result = 'Requested file not available.'
return fix_css_path(result, request.base_url)
img_path = Path(f'assets/img/{file_name}.svg')
if isfile(img_path):
return FileResponse(img_path)
logging.warning(f'Requested image {file_name} not available.')
@app.get('/api/eupt/{manifest}/manifest.json')
async def get_manifest(manifest: str, request: Request):
Loading