Added support for vinted labels
All checks were successful
DNSControl / build (push) Successful in 3m26s
All checks were successful
DNSControl / build (push) Successful in 3m26s
This commit is contained in:
parent
125d6eaf7c
commit
ef3421ff97
4 changed files with 54 additions and 3 deletions
17
main.py
17
main.py
|
@ -3,7 +3,7 @@ from bottle import route, request, static_file, run, redirect, HTTPResponse, hoo
|
|||
from random import randint
|
||||
from os import remove
|
||||
|
||||
from convert import convert_dhl, convert_hermes
|
||||
from convert import *
|
||||
|
||||
@route('/')
|
||||
def root():
|
||||
|
@ -39,6 +39,21 @@ def hermes():
|
|||
|
||||
return redirect(f"/download/{id}")
|
||||
|
||||
@route('/vinted', method='POST')
|
||||
def vinted():
|
||||
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_vinted(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