Skip to content

Commit 12fc58a

Browse files
DamianEdwardseerhardt
authored andcommitted
Return message at root for api service in starter template (#12408)
* Return message at root for api service in starter template Fixes #12405 * Update Python starter template * Update src/Aspire.ProjectTemplates/templates/aspire-py-starter/13.0/app/app.py Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com> --------- Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
1 parent 594b89f commit 12fc58a

File tree

2 files changed

+8
-0
lines changed
  • src/Aspire.ProjectTemplates/templates
    • aspire-py-starter/13.0/app
    • aspire-starter/13.0/Aspire-StarterApplication.1.ApiService

2 files changed

+8
-0
lines changed

src/Aspire.ProjectTemplates/templates/aspire-py-starter/13.0/app/app.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def get_redis_client():
5959
logger = logging.getLogger(__name__)
6060

6161

62+
if not os.path.exists("static"):
63+
@app.get("/")
64+
async def root():
65+
"""Root endpoint."""
66+
return "API service is running. Navigate to /weatherforecast to see sample data."
67+
6268
@app.get("/api/weatherforecast")
6369
//#if UseRedisCache
6470
async def weather_forecast(redis_client=fastapi.Depends(get_redis_client)):

src/Aspire.ProjectTemplates/templates/aspire-starter/13.0/Aspire-StarterApplication.1.ApiService/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#endif
2626
string[] summaries = ["Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"];
2727

28+
app.MapGet("/", () => "API service is running. Navigate to /weatherforecast to see sample data.");
29+
2830
app.MapGet("/weatherforecast", () =>
2931
{
3032
var forecast = Enumerable.Range(1, 5).Select(index =>

0 commit comments

Comments
 (0)