Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
crawler
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Project - Tarifs Crawler & API
crawler
Commits
1d67b6bc
Commit
1d67b6bc
authored
May 12, 2025
by
Marco Schmiedel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
e493dd11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
EeccxRouter.py
routes/EeccxRouter.py
+6
-6
No files found.
routes/EeccxRouter.py
View file @
1d67b6bc
...
...
@@ -55,7 +55,7 @@ blueprint = Blueprint(__name__.rsplit(".", 1)[-1], __name__)
s3_manager
=
S3Manager
()
# The function returns a JSON error response with the supplied message and status code.
def
_json_error
(
message
:
str
,
status_code
:
int
=
50
0
)
->
Response
:
def
_json_error
(
message
:
str
,
status_code
:
int
=
50
2
)
->
Response
:
# A JSON payload is assembled with status "ERROR" and the provided message.
payload
=
json
.
dumps
({
"status"
:
"ERROR"
,
"message"
:
message
},
ensure_ascii
=
False
)
...
...
@@ -290,12 +290,12 @@ def eeccx_pdf(tarif_id: str):
# The OAuth token is obtained and an error response is returned when token retrieval fails.
token
,
err
=
_get_token
()
if
err
:
return
_json_error
(
err
,
50
0
)
return
_json_error
(
err
,
50
2
)
# The partner API is called and an error response is returned when the API invocation fails.
api_json
,
err
=
_partner_api
(
token
,
tarif_id
,
options
)
if
err
:
return
_json_error
(
err
,
50
0
)
return
_json_error
(
err
,
50
2
)
# The pdf_url variable tries to extract the PCS or PCI PDF link from the partner API response JSON.
pdf_url
=
api_json
.
get
(
"pcsPdf"
)
or
api_json
.
get
(
"pciPdf"
)
...
...
@@ -303,12 +303,12 @@ def eeccx_pdf(tarif_id: str):
# The following conditional branch returns an error response when no PDF URL is present in the API response.
if
not
pdf_url
:
msg
=
api_json
.
get
(
"message"
)
or
"Keine PDF-URL in der API-Antwort."
return
_json_error
(
msg
,
50
0
)
return
_json_error
(
msg
,
50
2
)
# The PDF is downloaded and an error response is returned when the download fails.
pdf_bytes
,
err
=
_download_pdf
(
pdf_url
)
if
err
:
return
_json_error
(
err
,
50
0
)
return
_json_error
(
err
,
50
2
)
# A unique hash is generated so the temporary file and the S3 object name are collision‑free.
hash_name
=
_hash_id_options
(
tarif_id
,
options
)
...
...
@@ -325,7 +325,7 @@ def eeccx_pdf(tarif_id: str):
# The following conditional branch returns an error response when the S3 upload fails.
if
not
url
:
return
_json_error
(
f
"Upload zu S3 fehlgeschlagen für key={s3_key}"
,
50
0
)
return
_json_error
(
f
"Upload zu S3 fehlgeschlagen für key={s3_key}"
,
50
2
)
# A JSON response is returned containing the public URL of the uploaded PDF.
payload
=
json
.
dumps
({
"url"
:
url
},
ensure_ascii
=
False
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment