Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update endpoint name #20

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions wenling/web_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class GenerateArticleRequest(BaseModel):


class QueryArticleRequest(BaseModel):
database_id: str
start_date: str
end_date: str
tags: list[str]
Expand Down Expand Up @@ -80,9 +79,9 @@ async def generate_article(request: GenerateArticleRequest, api_key: str = Depen
return {"message": "Article generated successfully", "page_id": "123456789"}


@app.post("/query-pages/")
@app.post("/query-article/")
async def query_article(request: QueryArticleRequest, api_key: str = Depends(get_api_key)):
notion_query = NotionQuery(database_id=request.database_id, verbose=True)
notion_query = NotionQuery(database_id=os.environ.get("NOTION_DATABASE_ID"), verbose=True)
# Set default start date and end date if not provided
if not request.start_date:
request.start_date = str(datetime.date.today())
Expand All @@ -94,7 +93,7 @@ async def query_article(request: QueryArticleRequest, api_key: str = Depends(get
for page_id in pages:
url, title, tags = await notion_query.query_page_contents(page_id)
page_data.append({"title": title, "url": url, "tags": tags})
return {"message": "Query successful", "pages": page_data}
return {"message": "Query successful", "articles": page_data}


if __name__ == "__main__":
Expand Down
Loading