File tree Expand file tree Collapse file tree 13 files changed +229
-0
lines changed Expand file tree Collapse file tree 13 files changed +229
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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 ( ) ;
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ {
2+ "Logging" : {
3+ "LogLevel" : {
4+ "Default" : " Information" ,
5+ "Microsoft.AspNetCore" : " Warning" ,
6+ "Aspire.Hosting.Dcp" : " Warning"
7+ }
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ .venv
2+ uv.lock
3+ ** /__pycache__ /
Original file line number Diff line number Diff line change 1+ 3.12
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 1+ __pycache__
2+ .venv
Original file line number Diff line number Diff line change 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 ())
You can’t perform that action at this time.
0 commit comments