Initial commit
This commit is contained in:
commit
8d4b2bc943
17 changed files with 389 additions and 0 deletions
44
WebApp/Program.cs
Normal file
44
WebApp/Program.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
using Microsoft.OpenApi.Models;
|
||||
using WebApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
// Configure the HTTP request pipeline.
|
||||
if (builder.Environment.IsDevelopment())
|
||||
{
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Stitch a Ton", Description = "Meizar's stitch a ton solution", Version = "v1" });
|
||||
});
|
||||
}
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Stitch a Ton");
|
||||
});
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapPost("/api/image/generate",
|
||||
( RequestBody requestBody ) =>
|
||||
{
|
||||
ImageGenerator imageGenerator = new ImageGenerator();
|
||||
var png = imageGenerator.GenerateImage2( requestBody );
|
||||
return Results.File(png, "image/png", "result.png");
|
||||
})
|
||||
.WithName("ImageGenerator")
|
||||
.Produces(StatusCodes.Status200OK, contentType:"image/png");
|
||||
|
||||
app.Run();
|
||||
Loading…
Add table
Add a link
Reference in a new issue