Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LoadMoreItems.cs
1using System.Collections.Generic;
2using System.IO;
3using System.Threading.Tasks;
8using Waher.Script;
9
11{
13 {
14 public LoadMoreItems()
15 : base("/LoadMoreItems")
16 {
17 }
18
19 public override bool HandlesSubPaths => false;
20 public override bool UserSessions => true;
21 public bool AllowsPOST => true;
22
23 public async Task POST(HttpRequest Request, HttpResponse Response)
24 {
25 if (!Request.HasData)
26 throw new BadRequestException();
27
28 object Obj = await Request.DecodeDataAsync();
29 if (!(Obj is Dictionary<string, object> Obj2) ||
30 !Obj2.TryGetValue("from", out Obj) || !(Obj is string From) ||
31 !Obj2.TryGetValue("node", out Obj) || !(Obj is string Node))
32 {
33 throw new BadRequestException();
34 }
35
36 Variables v = new Variables(new Variable("From", From), new Variable("Node", Node));
37 MarkdownSettings Settings = PubSubContent.MarkdownContent.GetMarkdownSettings(v, true);
38 string Markdown = File.ReadAllText(Path.Combine(Gateway.RootFolder, "PublicNodeNext.md"));
39 MarkdownDocument Doc = await MarkdownDocument.CreateAsync(Markdown, Settings);
40 string HTML = HtmlDocument.GetBody(await Doc.GenerateHTML());
41
42 Response.ContentType = HtmlCodec.DefaultContentType;
43 await Response.Write(HTML);
44 }
45
46 }
47}
HTML encoder/decoder.
Definition: HtmlCodec.cs:13
const string DefaultContentType
Default Content-Type for HTML: text/html
Definition: HtmlCodec.cs:24
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:126
static string RootFolder
Web root folder.
Definition: Gateway.cs:2379
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:18
bool HasData
If the request has data.
Definition: HttpRequest.cs:74
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Definition: HttpRequest.cs:95
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:21
async 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.