-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (42 loc) · 1.23 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (42 loc) · 1.23 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
45
46
47
48
49
50
51
52
53
54
55
56
57
using WordCloud.Hubs;
using WordCloud.Services.Implementations;
using WordCloud.Services.Interfaces;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
// Add SignalR services
builder.Services.AddSignalR();
// Optional: Add CORS if needed
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
// Register application services
builder.Services.AddScoped<IWordCloudService, WordCloudService>();
// Configure logging
builder.Logging.ClearProviders();
builder.Logging.AddConsole();
var app = builder.Build();
// Ensure UseRouting is called before UseEndpoints
app.UseRouting();
// Configure CORS (optional, if using CORS)
app.UseCors();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthorization();
// Map routes and SignalR hub after UseRouting
app.UseEndpoints(endpoints =>
{
// Map the SignalR hub
endpoints.MapHub<WordCloudHub>("/wordcloudHub");
// Default controller route
app.MapControllerRoute(
name: "default",
pattern: "{controller=WordView}/{action=WordCloud}/{id?}");
});
app.Run();