This repository was archived by the owner on Jul 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (35 loc) · 1.49 KB
/
Program.cs
File metadata and controls
47 lines (35 loc) · 1.49 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
using Microsoft.EntityFrameworkCore;
using DbContext = Demnoboard.DbContext;
var builder = WebApplication.CreateBuilder(args);
string connection = builder.Configuration.GetConnectionString("MySQLConnection");
int versionMinor = Convert.ToInt16(builder.Configuration.GetConnectionString("Minor"));
int versionMajor = Convert.ToInt16(builder.Configuration.GetConnectionString("Major"));
int versionBuild = Convert.ToInt16(builder.Configuration.GetConnectionString("Build"));
builder.Services.AddControllersWithViews();
builder.Services.AddDbContext<DbContext>(options => options.UseMySql(connection, new MySqlServerVersion(new Version(versionMajor,versionMinor,versionBuild))));
builder.Services.Configure<CaptchaConfig>(builder.Configuration.GetSection("CaptchaConfig"));
builder.Services.Configure<BotConfig>(builder.Configuration.GetSection("BotConfig"));
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Posts/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Posts}/{action=Index}/");
app.Run();
public class CaptchaConfig
{
public string ServerKey { get; set; } = "";
}
public class BotConfig
{
public string Token { get; set; } = "";
public string ChatId { get; set; } = "";
}