Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LoadMoreItems.cs
2using System.IO;
3using System.Threading.Tasks;
4using Waher.Content;
9using Waher.Script;
10
12{
14 {
15 public LoadMoreItems()
16 : base("/LoadMoreItems")
17 {
18 }
19
20 public override bool HandlesSubPaths => false;
21 public override bool UserSessions => true;
22 public bool AllowsPOST => true;
23
24 public async Task POST(HttpRequest Request, HttpResponse Response)
25 {
26 if (!Request.HasData)
27 {
28 await Response.SendResponse(new BadRequestException());
29 return;
30 }
31
32 ContentResponse Content = await Request.DecodeDataAsync();
33 if (Content.HasError || !(Content.Decoded is Dictionary<string, object> Obj2) ||
34 !Obj2.TryGetValue("from", out object Obj) || !(Obj is string From) ||
35 !Obj2.TryGetValue("node", out Obj) || !(Obj is string Node))
36 {
37 await Response.SendResponse(new BadRequestException());
38 return;
39 }
40
41 Variables v = new Variables(new Variable("From", From), new Variable("Node", Node));
42 MarkdownSettings Settings = PubSubContent.MarkdownContent.GetMarkdownSettings(v, true);
43 string Markdown = File.ReadAllText(Path.Combine(Gateway.RootFolder, "PublicNodeNext.md"));
44 MarkdownDocument Doc = await MarkdownDocument.CreateAsync(Markdown, Settings);
45 string HTML = HtmlDocument.GetBody(await Doc.GenerateHTML());
46
47 Response.ContentType = HtmlCodec.DefaultContentType;
48 await Response.Write(HTML);
49 }
50
51 }
52}
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
HTML encoder/decoder.
Definition: HtmlCodec.cs:15
const string DefaultContentType
Default Content-Type for HTML: text/html
Definition: HtmlCodec.cs:26
static string GetBody(string Html)
Extracts the contents of the BODY element in a HTML string.
Contains a markdown document. This markdown document class supports original markdown,...
async Task< string > GenerateHTML()
Generates HTML from the markdown text.
static Task< MarkdownDocument > CreateAsync(string MarkdownText, params Type[] TransparentExceptionTypes)
Contains a markdown document. This markdown document class supports original markdown,...
Contains settings that the Markdown parser uses to customize its behavior.
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:147
static string RootFolder
Web root folder.
Definition: Gateway.cs:3142
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
Definition: HttpRequest.cs:22
bool HasData
If the request has data.
Definition: HttpRequest.cs:113
async Task< ContentResponse > DecodeDataAsync()
Decodes data sent in request.
Definition: HttpRequest.cs:139
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:23
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
Contains information about a variable.
Definition: Variable.cs:10
Collection of variables.
Definition: Variables.cs:25
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
bool AllowsPOST
If the POST method is allowed.
POST Interface for HTTP resources.