Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eupt-textapi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
subugoe
EUPT
eupt-textapi
Merge requests
!70
Resolve "Bild wird nicht angezeigt"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Bild wird nicht angezeigt"
36-bild-wird-nicht-angezeigt
into
develop
Overview
0
Commits
4
Pipelines
5
Changes
1
Merged
Michelle Weidling
requested to merge
36-bild-wird-nicht-angezeigt
into
develop
2 months ago
Overview
0
Commits
4
Pipelines
5
Changes
1
Expand
Closes
#36 (closed)
0
0
Merge request reports
Compare
develop
version 3
e4c1615d
2 months ago
version 2
5303e22b
2 months ago
version 1
418996b6
2 months ago
develop (base)
and
latest version
latest version
78c36eb5
4 commits,
2 months ago
version 3
e4c1615d
3 commits,
2 months ago
version 2
5303e22b
2 commits,
2 months ago
version 1
418996b6
1 commit,
2 months ago
1 file
+
8
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/textapi.py
+
8
−
10
Options
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