Added support for vinted labels
All checks were successful
DNSControl / build (push) Successful in 3m26s

This commit is contained in:
fleaz 2025-05-25 15:55:42 +02:00
parent 125d6eaf7c
commit ef3421ff97
Signed by: fleaz
GPG key ID: 935474624265FE8F
4 changed files with 54 additions and 3 deletions

17
main.py
View file

@ -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"