Skip to content

Commit

Permalink
Better handle of date param and standarize URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimas committed Apr 3, 2024
1 parent 0756e53 commit c262468
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions web_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,14 @@ def memory_search_api():
return Response(search.get_json(), mimetype="application/json")


@app.route("/stats", methods=["GET"])
@app.route("/stats/", methods=["GET"])
def stats_api():
requested = request.args.get("date")
date_requested = datetime.datetime.strptime(requested, "%Y-%m-%d")
try:
requested = request.args.get('date')
date_requested = datetime.datetime.strptime(requested, '%Y-%m-%d')
except Exception as e:
return Response({}, mimetype="application/json", status=400)

stats = Stats()
return Response(stats.get_json(date_requested), mimetype="application/json")

Expand Down

0 comments on commit c262468

Please sign in to comment.