|
|
@@ -1,6 +1,6 @@
|
|
|
from pathlib import Path
|
|
|
# import magic
|
|
|
-from fastapi import FastAPI, BackgroundTasks
|
|
|
+from fastapi import FastAPI, BackgroundTasks, HTTPException
|
|
|
from starlette.responses import FileResponse
|
|
|
# http://127.0.0.1:8000/
|
|
|
# http://127.0.0.1:8000/docs
|
|
|
@@ -25,6 +25,8 @@ async def root():
|
|
|
@app.get("/{name}")
|
|
|
async def ontology(name: str, background_tasks: BackgroundTasks):
|
|
|
file_path = data_path / Path(name)
|
|
|
+ if not file_path.exists():
|
|
|
+ raise HTTPException(status_code=404, detail=f"Ontology {name} not found!")
|
|
|
# mime = magic.Magic(mime=True)
|
|
|
# media_type = mime.from_file(file_path)
|
|
|
media_type = "text/xml"
|