From aee8b18c2031c09078df9701cc656c26d9836156 Mon Sep 17 00:00:00 2001 From: Aravindan K Date: Tue, 2 Dec 2025 17:02:33 +0530 Subject: [PATCH] Update main.py added new countries API --- main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 4640f23..98f86f9 100644 --- a/main.py +++ b/main.py @@ -35,7 +35,12 @@ def countries(): def monthly_average(country: str, city: str, month: str): return data[country][city][month] +# Create a new route that exposes the cities of a country: +@app.get('/countries/{country}') +def cities(country: str): + return list(data[country].keys()) + # Generate the OpenAPI schema: openapi_schema = app.openapi() with open(join(wellknown_path, "openapi.json"), "w") as f: - json.dump(openapi_schema, f) \ No newline at end of file + json.dump(openapi_schema, f)