Explorar el Código

Merge branch 'release-0.0.14'

Arkadiusz Ryś hace 3 años
padre
commit
a5a8af5c05
Se han modificado 3 ficheros con 8 adiciones y 2 borrados
  1. 4 0
      HISTORY.rst
  2. 1 1
      ontopoint/__init__.py
  3. 3 1
      ontopoint/main.py

+ 4 - 0
HISTORY.rst

@@ -2,6 +2,10 @@
 History
 =======
 
+0.0.14 (2023-01-13)
+------------------
+* Handle unknown ontologies.
+
 0.0.2 (2023-01-13)
 ------------------
 * Add release engineering.

+ 1 - 1
ontopoint/__init__.py

@@ -1,3 +1,3 @@
 """Ontology server."""
-__version__ = "0.0.13"
+__version__ = "0.0.14"
 __version_info__ = tuple((int(num) if num.isdigit() else num for num in __version__.replace("-", ".", 1).split(".")))

+ 3 - 1
ontopoint/main.py

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