Skip to content

Commit 91875c6

Browse files
Copilotaaronpowell
andcommitted
Revert deletion of Python examples and tests
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
1 parent ee45cff commit 91875c6

File tree

13 files changed

+229
-0
lines changed

13 files changed

+229
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<Sdk Name="Aspire.AppHost.Sdk" Version="$(AspireAppHostSdkVersion)"/>
3+
4+
<PropertyGroup>
5+
<OutputType>Exe</OutputType>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsAspireHost>true</IsAspireHost>
9+
<UserSecretsId>5a6548a5-b5dd-40f0-876a-9e3d4ac91fd1</UserSecretsId>
10+
<NoWarn>$(NoWarn);ASPIREHOSTINGPYTHON001</NoWarn>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Aspire.Hosting.AppHost" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.Python.Extensions\CommunityToolkit.Aspire.Hosting.Python.Extensions.csproj" IsAspireProjectResource="false" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma warning disable CS0612 // Type or member is obsolete
2+
#pragma warning disable CS0618 // Type or member is obsolete
3+
var builder = DistributedApplication.CreateBuilder(args);
4+
5+
builder.AddUvicornApp("uvicornapp", "../uvicornapp-api", "main:app");
6+
7+
builder.AddUvApp("uvapp", "../uv-api", "uv-api")
8+
.WithHttpEndpoint(env: "PORT");
9+
10+
builder.Build().Run();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"https": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "https://localhost:17247;http://localhost:15071",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_ENVIRONMENT": "Development",
12+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21120",
13+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22298"
14+
}
15+
},
16+
"http": {
17+
"commandName": "Project",
18+
"dotnetRunMessages": true,
19+
"launchBrowser": true,
20+
"applicationUrl": "http://localhost:15071",
21+
"environmentVariables": {
22+
"ASPNETCORE_ENVIRONMENT": "Development",
23+
"DOTNET_ENVIRONMENT": "Development",
24+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19155",
25+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20207"
26+
}
27+
}
28+
}
29+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning",
6+
"Aspire.Hosting.Dcp": "Warning"
7+
}
8+
}
9+
}

examples/python/uv-api/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.venv
2+
uv.lock
3+
**/__pycache__/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[project]
2+
name = "uv-api"
3+
version = "0.1.0"
4+
description = "Test project for uv-api"
5+
authors = [
6+
{ name = "Tommaso Stocchi", email = "tstocchi@microsoft.com" }
7+
]
8+
requires-python = ">=3.12"
9+
dependencies = [
10+
"fastapi>=0.115.6",
11+
"uvicorn>=0.32.1",
12+
]
13+
14+
[project.scripts]
15+
uv-api = "uv_api:main"
16+
17+
[build-system]
18+
requires = ["hatchling"]
19+
build-backend = "hatchling.build"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from fastapi import FastAPI
2+
import uvicorn
3+
import os
4+
5+
app = FastAPI()
6+
7+
@app.get("/")
8+
def read_root():
9+
return {"message": "Hello, World!"}
10+
11+
def main() -> None:
12+
port = int(os.environ.get("PORT", 8000))
13+
uvicorn.run(app, host="127.0.0.1", port=port)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__
2+
.venv
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
import asyncio
3+
import uvicorn
4+
5+
async def app(scope, receive, send):
6+
assert scope['type'] == 'http'
7+
8+
await send({
9+
'type': 'http.response.start',
10+
'status': 200,
11+
'headers': [
12+
[b'content-type', b'text/plain'],
13+
],
14+
})
15+
await send({
16+
'type': 'http.response.body',
17+
'body': b'Hello, world!',
18+
})
19+
20+
async def main():
21+
config = uvicorn.Config("main:app", log_level="info")
22+
server = uvicorn.Server(config)
23+
await server.serve()
24+
25+
if __name__ == "__main__":
26+
asyncio.run(main())

0 commit comments

Comments
 (0)