-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (34 loc) · 1.19 KB
/
Copy pathProgram.cs
File metadata and controls
44 lines (34 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using YoutubeVideoSentiment.Services;
using YoutubeVideoSentiment.Models;
var builder = WebApplication.CreateBuilder(args);
// API anahtarını configuration'dan al
var apiKey = builder.Configuration["YouTubeApiKey"] ?? Environment.GetEnvironmentVariable("YOUTUBE_API_KEY");
// Servisleri DI container'a ekle
if (!string.IsNullOrWhiteSpace(apiKey))
{
builder.Services.AddSingleton<IYouTubeCommentService>(sp => new YouTubeCommentService(apiKey));
}
else
{
builder.Services.AddScoped<IYouTubeCommentService, YouTubeCommentService>();
}
builder.Services.AddScoped<ISentimentAnalysisService, SentimentAnalysisService>();
builder.Services.AddScoped<ISentimentReportService, SentimentReportService>();
builder.Services.AddControllers();
// CORS ayarları (React frontend için)
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowReactApp", policy =>
{
policy.WithOrigins("http://localhost:3000", "http://localhost:5173")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
app.UseCors("AllowReactApp");
app.UseAuthorization();
app.MapControllers();
app.Run();