-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from imxcstar/main
分离出asp.netcore,项目名字修改
- Loading branch information
Showing
23 changed files
with
444 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Demo\Demo.csproj" /> | ||
<ProjectReference Include="..\Gradio.Net.AspNetCore\Gradio.Net.AspNetCore.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Gradio.Net | ||
{ | ||
public static class App | ||
{ | ||
public static void Launch(Blocks blocks, Action<GradioServiceConfig>? additionalConfigurationAction = null, params string[] args) | ||
{ | ||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddGradio(); | ||
|
||
WebApplication app = builder.Build(); | ||
|
||
app.UseGradio(blocks, additionalConfigurationAction); | ||
|
||
app.Run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Gradio.Net.AspNetCore | ||
{ | ||
internal class EventWorker : BackgroundService | ||
{ | ||
private readonly GradioApp _gradioApp; | ||
|
||
public EventWorker(GradioApp gradioApp) | ||
{ | ||
_gradioApp = gradioApp; | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
await _gradioApp.StartEventLoopAsync(stoppingToken); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Gradio.Net.AspNetCore | ||
{ | ||
internal class FileMiddleware | ||
{ | ||
private readonly RequestDelegate _next; | ||
|
||
public FileMiddleware(RequestDelegate next) | ||
{ | ||
_next = next; | ||
} | ||
|
||
public async Task InvokeAsync(HttpContext httpContext, GradioApp gradioApp) | ||
{ | ||
string path = httpContext.Request.Path.ToString(); | ||
const string FILE_URL = "/file="; | ||
if (path.StartsWith(FILE_URL)) | ||
{ | ||
(string filePath, string contentType) = await gradioApp.GetUploadedFile(path.Substring(FILE_URL.Length)); | ||
await httpContext.Response.SendFileAsync(filePath); | ||
return; | ||
} | ||
await _next(httpContext); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<PackageId>Gradio.Net.AspNetCore</PackageId> | ||
<Version>0.0.9</Version> | ||
<Title>Gradio.Net</Title> | ||
<Authors>feiyun0112</Authors> | ||
<Description>Gradio for .NET – a port of Gradio, an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitrary Python function. Gradio for .NET – 基于 Gradio 的 .NET 移植,Gradio 是一个开源 Python 包,允许你为机器学习模型、API 或任何任意 Python 函数快速构建演示或 Web 应用程序。</Description> | ||
<ProjectUrl>https://github.com/feiyun0112/Gradio.Net</ProjectUrl> | ||
<Tags>Gradio, UI, UI-Components</Tags> | ||
<RepositoryUrl>https://github.com/feiyun0112/Gradio.Net</RepositoryUrl> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
|
||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
<RequireLicenseAcceptance>false</RequireLicenseAcceptance> | ||
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectCapability Include="AspNetCore" /> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\README.md"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Gradio.Net\Gradio.Net.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.Extensions.FileProviders.Embedded; | ||
using Microsoft.Extensions.FileProviders; | ||
using Microsoft.Extensions.Primitives; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Gradio.Net.AspNetCore | ||
{ | ||
internal class StaticFileProvider : IFileProvider | ||
{ | ||
private readonly GradioApp _gradioApp; | ||
|
||
internal StaticFileProvider(GradioApp gradioApp) | ||
{ | ||
_gradioApp = gradioApp; | ||
} | ||
|
||
public IFileInfo GetFileInfo(string subpath) | ||
{ | ||
return _gradioApp.GetFileInfo(subpath); | ||
} | ||
public IDirectoryContents GetDirectoryContents(string subpath) | ||
{ | ||
return null; | ||
} | ||
|
||
public IChangeToken Watch(string filter) | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.