-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
38 lines (33 loc) · 1.32 KB
/
Copy pathProgram.cs
File metadata and controls
38 lines (33 loc) · 1.32 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
using School_Driving.Controllers;
using System.Data.SQLite;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseCors();
app.UseAuthorization();
app.MapControllers();
app.UseStaticFiles();
app.MapGet("/", () => Results.Redirect("/index.html"));
SQLiteConnection connection = DatabaseConnector.Db();
SQLiteCommand command = connection.CreateCommand();
command.CommandText = "PRAGMA foreign_keys = ON;" +
"CREATE TABLE if not Exists `Question` " +
"(`QuestionID` integer PRIMARY KEY, `Question` text not NULL, `Option1` text not NULL, `Option2` text not NULL, `Option3` text NOT NULL, " +
"`Answer` text not NULL, `Points` integer not NULL, `Image` text not NULL); " +
"CREATE TABLE if not Exists `Score` " +
"(`ScoreID` integer PRIMARY KEY, `Username` text not NULL, `ScoreValue` integer not NULL, `TotalPoints` integer not NULL, Timestamp datetime NOT NULL); ";
command.ExecuteNonQuery();
command.Dispose();
app.Run();