Skip to content

Commit

Permalink
Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
epeters-jrmngndr committed Aug 14, 2024
1 parent 9746e0e commit 48aa3e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion wiki_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@
@app.get("/articles", include_in_schema=False)
@app.get("/articles/")
def list_articles():
"""List all articles in memory"""
return list(stored_articles.keys())


@app.get("/articles/{article_name}", response_class=HTMLResponse)
@app.get("/articles/{article_name}/", include_in_schema=False)
def get_article(article_name: str, response: HTMLResponse):
"""Retrieve an article by name"""
if article_name in stored_articles.keys():
return HTMLResponse(content=stored_articles[article_name])
response.status_code = status.HTTP_404_NOT_FOUND


@app.put("/articles/{article_name}", status_code=200)
async def put_article(article_name: str, response: Response, request: Request):
"""Create or update an article"""
body = await request.body()
if article_name not in stored_articles.keys():
response.status_code = status.HTTP_201_CREATED

stored_articles[article_name] = body.decode("utf-8")

0 comments on commit 48aa3e9

Please sign in to comment.