Compare commits
2 Commits
1e301c04c0
...
2b09371cbf
Author | SHA1 | Date | |
---|---|---|---|
2b09371cbf | |||
0af50c21ae |
10
src/main.py
10
src/main.py
@ -33,7 +33,7 @@ def get_root(request: Request):
|
||||
if request.url.path != "/":
|
||||
raise HTTPException(status_code=404)
|
||||
|
||||
return renderTemplate("main.html")
|
||||
return render("main.html")
|
||||
|
||||
|
||||
@app.post("/detect/{strength}")
|
||||
@ -43,6 +43,9 @@ def post_detect(file: Image, strength: DetectionStrength):
|
||||
print("\nWorking on: " + file_name)
|
||||
print("\nStrength: " + strength + "\n")
|
||||
|
||||
if not os.path.exists("data/"):
|
||||
os.makedirs("data")
|
||||
|
||||
with open("data/" + file_name, "wb") as f:
|
||||
f.write(b64decode(file.file_contents))
|
||||
|
||||
@ -104,6 +107,5 @@ def get_models_for_detection_strength(strength: DetectionStrength):
|
||||
return ["db_resnet50", "vitstr_small"]
|
||||
|
||||
|
||||
def renderTemplate(template, context={}):
|
||||
template = env.get_template(template)
|
||||
return HTMLResponse(template.render(context))
|
||||
def render(template, context={}):
|
||||
return HTMLResponse(env.get_template(template).render(context))
|
||||
|
Loading…
x
Reference in New Issue
Block a user