Added support for 'Hermes Paketschein'
This commit is contained in:
parent
ca219e56c3
commit
ce057bd4b4
3 changed files with 49 additions and 2 deletions
19
main.py
19
main.py
|
@ -3,14 +3,14 @@ from bottle import route, request, static_file, run, redirect, HTTPResponse, hoo
|
|||
from random import randint
|
||||
from os import remove
|
||||
|
||||
from convert import convert_dhl
|
||||
from convert import convert_dhl, convert_hermes
|
||||
|
||||
@route('/')
|
||||
def root():
|
||||
return static_file('index.html', root='templates')
|
||||
|
||||
@route('/dhl', method='POST')
|
||||
def do_upload():
|
||||
def dhl():
|
||||
upload = request.files.get('upload')
|
||||
if upload.content_type != "application/pdf":
|
||||
return HTTPResponse(status=400, body="Bad file")
|
||||
|
@ -24,6 +24,21 @@ def do_upload():
|
|||
|
||||
return redirect(f"/download/{id}")
|
||||
|
||||
@route('/hermes', method='POST')
|
||||
def hermes():
|
||||
upload = request.files.get('upload')
|
||||
if upload.content_type != "application/pdf":
|
||||
return HTTPResponse(status=400, body="Bad file")
|
||||
|
||||
id = randint(100000,999999)
|
||||
upload.save(f"./uploads/{id}.pdf")
|
||||
convert_hermes(id)
|
||||
print(f"converted {upload.filename} as {id}.pdf")
|
||||
# delete upload file
|
||||
remove(f"./uploads/{id}.pdf")
|
||||
|
||||
return redirect(f"/download/{id}")
|
||||
|
||||
@route('/download/<id>')
|
||||
def download(id):
|
||||
filename = f"{id}.pdf"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue