Rename some parameters; return curation ID
This commit is contained in:
parent
31c27daca4
commit
a88a1a3e95
2 changed files with 18 additions and 5 deletions
|
@ -7,6 +7,7 @@ from pathlib import Path
|
|||
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
from mwmbl import background
|
||||
from mwmbl.crawler import app as crawler
|
||||
|
@ -66,6 +67,14 @@ def run():
|
|||
# Initialize FastApi instance
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
search_router = search.create_router(ranker)
|
||||
app.include_router(search_router)
|
||||
|
||||
|
|
|
@ -36,16 +36,16 @@ class Curation(BaseModel):
|
|||
|
||||
|
||||
class CurateMove(Curation):
|
||||
url_old_index: int
|
||||
url_new_index: int
|
||||
old_index: int
|
||||
new_index: int
|
||||
|
||||
|
||||
class CurateDelete(Curation):
|
||||
url_delete_index: int
|
||||
delete_index: int
|
||||
|
||||
|
||||
class CurateAdd(Curation):
|
||||
url_insert_index: int
|
||||
insert_index: int
|
||||
url: str
|
||||
|
||||
|
||||
|
@ -91,7 +91,11 @@ def create_router() -> APIRouter:
|
|||
"url": url,
|
||||
}
|
||||
request = requests.post(urljoin(LEMMY_URL, "api/v3/post"), json=create_post)
|
||||
if request.status_code != 200:
|
||||
return Response(content=request.content, status_code=request.status_code, media_type="text/json")
|
||||
data = request.json()
|
||||
curation_id = data["post_view"]["post"]["id"]
|
||||
return {"curation_id": curation_id}
|
||||
|
||||
@router.post("/curation/move")
|
||||
def user_move_result(curate_move: CurateMove):
|
||||
|
|
Loading…
Reference in a new issue