mirror of
https://gitlab.com/2-chainz/2-chainz-rest.git
synced 2025-08-03 03:51:24 +00:00
added param for more than 1 quote
This commit is contained in:
@@ -6,5 +6,16 @@ from . import quotes
|
||||
|
||||
|
||||
def main(req: func.HttpRequest) -> func.HttpResponse:
|
||||
batch = req.params.get("batch")
|
||||
random.shuffle(quotes.quotes)
|
||||
if batch is not None:
|
||||
try:
|
||||
batch = int(batch)
|
||||
except ValueError:
|
||||
return func.HttpResponse(
|
||||
"'batch' param must be an integer.", status_code=400
|
||||
)
|
||||
return func.HttpResponse(json.dumps({"quotes": quotes.quotes[0:batch]}))
|
||||
|
||||
logging.info("Python HTTP trigger function processed a request.")
|
||||
return func.HttpResponse(json.dumps({"quote": random.choice(quotes.quotes)}))
|
||||
return func.HttpResponse(json.dumps({"quote": quotes.quotes[0]}))
|
||||
|
Reference in New Issue
Block a user