Skip to content
Snippets Groups Projects
Commit eea94b2f authored by Jacob Benz's avatar Jacob Benz
Browse files

make authority-api fit into deployment system

parent bbb20f6d
No related branches found
No related tags found
No related merge requests found
......@@ -7,4 +7,4 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app
CMD ["fastapi", "run", "--workers", "8", "app/main.py", "--port", "5700"]
\ No newline at end of file
CMD ["fastapi", "run", "--workers", "8", "app/main.py", "--port", "5700", "--root-path", "/authority-api/"]
\ No newline at end of file
......@@ -14,4 +14,4 @@ This application is intended to be used as a dependency running for LEAF-Writer.
# Deployment
This application is intended to be deployed together with a LEAF-Writer instance, see [LEAF-Writer Deployment](https://code.fbi.h-da.de/leaf-writer-x/leafwriter-x/-/wikis/Simplified_Deployment).
If you want or need a standalone deployment, you can start by building upon the provided ```Dockerfile```. When using this Dockerfile the application runs on port ```5700```.
\ No newline at end of file
If you want or need a standalone deployment, you can start by building upon the provided ```Dockerfile```. When using this Dockerfile the application runs on port ```5700``` with the route-prefix of ```/authority-api```.
\ No newline at end of file
......@@ -19,6 +19,7 @@
from typing import Union
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
import requests
import os
......@@ -44,6 +45,14 @@ class ResultForGivenAuthority(BaseModel):
matches: list[ResultItem | None]
app = FastAPI()
# CORS is always there to ruin your day as well!
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
def dbpedia(entity: str, typeName: str | None, numEntities: int):
request_url = "https://lookup.dbpedia.org/api/search"
......@@ -218,7 +227,6 @@ def viaf(entity:str, queryType: str, numEntities: int):
if (result.status_code == requests.codes.ok):
return_list: list = []
if "searchRetrieveResponse" in result.json() and "records" in result.json()["searchRetrieveResponse"] and "record" in result.json()["searchRetrieveResponse"]["records"] and isinstance(result.json()["searchRetrieveResponse"]["records"]["record"], list):
print(len(result.json()["searchRetrieveResponse"]["records"]["record"]))
for item in result.json()["searchRetrieveResponse"]["records"]["record"]:
candidate = item["recordData"]
cluster = candidate["v:VIAFCluster"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment