From 0ce3d4de2afa00840bb644978ad6fe1170a8a95d Mon Sep 17 00:00:00 2001 From: Phil Bajsicki Date: Sat, 20 Apr 2024 13:48:53 +0200 Subject: [PATCH] Fixed up JSON API key names --- README.org | 5 +++-- pydiceprob.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index f3e91c8..228b9a2 100644 --- a/README.org +++ b/README.org @@ -77,6 +77,7 @@ from fastapi import FastAPI, Header #+end_src ** Pretty print and usage printer +Pretty print so output is legible. #+begin_src python pp = pp.Printer = pprint.PrettyPrinter(indent=2, compact=True) @@ -108,10 +109,10 @@ async def api_get(k: int = Header(default=None)): return {"message": "Header k must be an integer between 6 and 100 inclusive or not present."} if k is None: result = one_turn_table(100) - return {"Probabilities of throwing the highest number on dice of size": result} + return {"Probabilities-dice": result} elif k >= 6 and k <= 100: result = one_turn_single(k) - return {f"Probability of throwing the highest number of dice of size {k}": result} + return {f"Probability-dice-size-{k}": result} else: return {"message": "Usage: no request body, use header k to specify what probability you want, if no k, then a table is given between dice sizes 6 and 100 inclusive."} diff --git a/pydiceprob.py b/pydiceprob.py index 1aea949..e6369cd 100644 --- a/pydiceprob.py +++ b/pydiceprob.py @@ -26,10 +26,10 @@ async def api_get(k: int = Header(default=None)): return {"message": "Header k must be an integer between 6 and 100 inclusive or not present."} if k is None: result = one_turn_table(100) - return {"Probabilities of throwing the highest number on dice of size": result} + return {"Probabilities-dice": result} elif k >= 6 and k <= 100: result = one_turn_single(k) - return {f"Probability of throwing the highest number of dice of size {k}": result} + return {f"Probability-dice-size-{k}": result} else: return {"message": "Usage: no request body, use header k to specify what probability you want, if no k, then a table is given between dice sizes 6 and 100 inclusive."}