Add simple logging
This commit is contained in:
parent
a5b9ee4cd7
commit
22414a4378
|
@ -91,16 +91,21 @@ def result_to_dict(res, base_url):
|
||||||
|
|
||||||
@app.put("/images/")
|
@app.put("/images/")
|
||||||
async def analyze_image(file: UploadFile, request: Request):
|
async def analyze_image(file: UploadFile, request: Request):
|
||||||
|
print("Initiating file receipt, url: " + str(request.url))
|
||||||
base_url = re.sub(r'\/images\/$', '/analyzed_images/', str(request.url))
|
base_url = re.sub(r'\/images\/$', '/analyzed_images/', str(request.url))
|
||||||
infile = open(incoming_dir / file.filename)
|
infile = open(incoming_dir / file.filename)
|
||||||
file_hash = hashlib.sha256()
|
file_hash = hashlib.sha256()
|
||||||
with open(infile, mode="wb") as f:
|
with open(infile, mode="wb") as f:
|
||||||
chunk = f.read(buffer_size)
|
chunk = f.read(buffer_size)
|
||||||
while chunk:
|
while chunk:
|
||||||
|
print("writing chunk")
|
||||||
file_hash.update(chunk)
|
file_hash.update(chunk)
|
||||||
infile.write(chunk)
|
infile.write(chunk)
|
||||||
chunk=f.read(buffer_size)
|
chunk=f.read(buffer_size)
|
||||||
|
print("saving complete")
|
||||||
|
print("analyzing image")
|
||||||
result = detector.detect_objects(infile, file_hash.hexdigest() + ".png")
|
result = detector.detect_objects(infile, file_hash.hexdigest() + ".png")
|
||||||
|
print("image analyzed")
|
||||||
remove(infile)
|
remove(infile)
|
||||||
return result_to_dict(result, base_url)
|
return result_to_dict(result, base_url)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue