James!!
Explore posts from serversim not getting any response on these endpoints
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
// Register services
builder.Services.AddHttpClient("OpenAI", client =>
{
client.BaseAddress = new Uri("https://api.openai.com/v1/");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {builder.Configuration["OpenAI:ApiKey"]}");
});
builder.Services.AddScoped<PdfService>();
builder.Services.AddScoped<ContractAnalysisService>();
builder.Services.AddScoped<DatabaseService>();
var app = builder.Build();
// Initialize database
using (var scope = app.Services.CreateScope())
{
var dbService = scope.ServiceProvider.GetRequiredService<DatabaseService>();
dbService.InitializeDatabase();
}
// Configure the HTTP request pipeline
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseCors("AllowAll");
app.UseHttpsRedirection();
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
});
// Register services
builder.Services.AddHttpClient("OpenAI", client =>
{
client.BaseAddress = new Uri("https://api.openai.com/v1/");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {builder.Configuration["OpenAI:ApiKey"]}");
});
builder.Services.AddScoped<PdfService>();
builder.Services.AddScoped<ContractAnalysisService>();
builder.Services.AddScoped<DatabaseService>();
var app = builder.Build();
// Initialize database
using (var scope = app.Services.CreateScope())
{
var dbService = scope.ServiceProvider.GetRequiredService<DatabaseService>();
dbService.InitializeDatabase();
}
// Configure the HTTP request pipeline
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseCors("AllowAll");
app.UseHttpsRedirection();
22 replies