44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
|
|
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();
|