-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (44 loc) · 1.57 KB
/
Program.cs
File metadata and controls
50 lines (44 loc) · 1.57 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
// Copyright (C) 2016 by Barend Erasmus, David Jeske and donated to the public domain
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using SimpleHttpServer;
using SimpleHttpServer.Models;
using SimpleHttpServer.RouteHandlers;
namespace SimpleHttpServer.App
{
class Program
{
static void Main(string[] args)
{
log4net.Config.XmlConfigurator.Configure();
var route_config = new List<Models.Route>() {
new Route {
Name = "Hello Handler",
UrlRegex = @"^/$",
Method = "GET",
Callable = (HttpRequest request) => {
return new HttpResponse()
{
ContentAsUTF8 = "Hello from SimpleHttpServer",
ReasonPhrase = "OK",
StatusCode = "200"
};
}
},
//new Route {
// Name = "FileSystem Static Handler",
// UrlRegex = @"^/Static/(.*)$",
// Method = "GET",
// Callable = new FileSystemRouteHandler() { BasePath = @"C:\Tmp", ShowDirectories=true }.Handle,
//},
};
HttpServer httpServer = new HttpServer(8080, route_config);
Thread thread = new Thread(new ThreadStart(httpServer.Listen));
thread.Start();
}
}
}