Skip to content

Commit

Permalink
fix: saving file to tmp folder and also using original file name
Browse files Browse the repository at this point in the history
  • Loading branch information
CS76 committed Mar 10, 2023
1 parent 6ccf663 commit cb73dcb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/routers/chem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from typing import Optional
from rdkit import Chem
import urllib.request
import urlparse
import mimetypes
# from ..database import db
# from fastapi_pagination import Page, add_pagination, paginate
from rdkit.Chem.EnumerateStereoisomers import (
Expand Down Expand Up @@ -169,8 +171,9 @@ async def extract_chemicalinfo(request: Request):
body = await request.json()
image_path = body["path"]
reference = body["reference"]
split = urlparse.urlsplit(image_path)
filename = "/tmp/" + split.path.split("/")[-1]
if image_path:
filename = reference + ".png"
urllib.request.urlretrieve(image_path, filename)
smiles = predict_SMILES(filename)
os.remove(filename)
Expand Down

0 comments on commit cb73dcb

Please sign in to comment.