-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHome.cs
More file actions
39 lines (33 loc) · 1.16 KB
/
Copy pathHome.cs
File metadata and controls
39 lines (33 loc) · 1.16 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
using Microsoft.AspNetCore.Http;
namespace dnproto.pds.xrpc;
/// <summary>
/// Handler for the home page "/".
///
/// Serves an index.html file from the static directory if it exists,
/// otherwise returns a small default page linking to the dnproto project.
/// </summary>
public class Home : BaseXrpcCommand
{
public IResult GetResponse()
{
IncrementStatistics();
//
// Serve {dataDir}/static/index.html if it exists.
//
string indexPath = Path.Combine(Pds.LocalFileSystem.GetPath_StaticDir(), "index.html");
if (File.Exists(indexPath))
{
var html = File.ReadAllText(indexPath);
return Results.Content(html, "text/html", statusCode: 200);
}
//
// Otherwise, return a small default page.
//
string defaultHtml =
"<!DOCTYPE html><html><head><meta charset=\"utf-8\">" +
"<title>dnproto</title></head><body>" +
"<p><a href=\"https://github.com/threddyrex/dnproto\">dnproto</a> PDS implementation</p>" +
"</body></html>";
return Results.Content(defaultHtml, "text/html", statusCode: 200);
}
}