all repos — h3rald @ 014a4bffb19de55f0ef2494bc119480df3adb9b6

The sources of https://h3rald.com

Updates.
h3rald h3rald@h3rald.com
Mon, 13 Jan 2020 12:47:02 +0000
commit

014a4bffb19de55f0ef2494bc119480df3adb9b6

parent

39994bbe6db5f27b0bcfc4aeb2c43b16c4838c7c

2 files changed, 40 insertions(+), 30 deletions(-)

jump to
M assets/min/Min_DeveloperGuide.htmassets/min/Min_DeveloperGuide.htm

@@ -9334,12 +9334,12 @@ <p>Performs an HTTP request.</p>

<div class="sidebar"><p>Example</p> -<p>The following code constructs a <span class="kwd">request</span> dictionary using the <strong>tap</strong> operator and passes it to the <strong>request</strong> operator to perform an HTTP GET request to <a href="http://httpbin.org/ip">http://httpbin.org/ip</a>:</p> +<p>The following code constructs a <span class="kwd">request</span> dictionary and passes it to the <strong>request</strong> operator to perform an HTTP GET request to <a href="http://httpbin.org/ip">http://httpbin.org/ip</a>:</p> -<pre><code>{} ( - ("GET" %method) - ("http://httpbin.org/ip" %url) -) tap request +<pre><code>{} + "GET" %method) + "http://httpbin.org/ip" %url +request </code></pre></div></div> <p><a id="min-operator-id-start-server"></a>

@@ -9364,32 +9364,42 @@ <div class="sidebar"><p>Example</p>

<p>The following program starts a very simple HTTP server that can display the current timestamp or date and time in ISO 8601 format:</p> -<pre><code>( - :req - req /url :url - ;Set response body - "Invalid Request: $1" (url) =&gt; % :body - ("/datetime" url ==) ( - timestamp datetime @body - ) when - ("/timestamp" url ==) ( - timestamp string @body - ) when - ("/shutdown" url ==) ( - "Stopping server..." puts! - stop-server - ) when - ;Prepare response - {} body %body -) =handler +<pre><code>; Define the request handler +( + ; Assume there is a request on the stack, take it off and give it the name req + :req + ; Let's see what we got (print req to standard out) + "THE REQUEST:" puts! req puts! + ; The request is a dictionary, we retrieve the value for the key url, and give it the name url + req /url :url + "THE URL is '$1'." url quote % puts! + ; Constuct response body + ( + (("/datetime" url ==) (timestamp datetime)) + (("/timestamp" url ==) (timestamp string)) + (("/shutdown" url ==) ("Stopping server..." puts! stop-server)) + (("/" url ==) ( + ; this is a bit short, but works with Chrome, IE, Edge, Safari + "&lt;a href='/datetime'&gt;datetime&lt;/a&gt;, &lt;a href='/timestamp'&gt;timestamp&lt;/a&gt;, &lt;a href='/shutdown'&gt;stop&lt;/a&gt;" + )) + ((true) ("Invalid Request: $1" url quote %)) + ) case + :body + ; Prepare the response + {} body %body + dup puts! +) +; The request handler is ready, give it the name handler +=handler + +; Create the parameter dictionary for the server +{} +handler %handler +5555 %port -;Start server +; Start server "Server started on port 5555." puts! "Press Ctrl+C to stop." puts! - -{} - handler %handler - 5555 %port start-server </code></pre></div></div>

@@ -9401,7 +9411,7 @@

<p>Stops the currently-running HTTP server. This operator should be used within an HTTP server handler quotation.</p></div> </div> <div id="footer"> - <p><span class="copy"></span> Fabio Cevasco &ndash; January 10, 2020</p> + <p><span class="copy"></span> Fabio Cevasco &ndash; January 13, 2020</p> <p><span>Powered by</span> <a href="https://h3rald.com/hastyscribe"><span class="hastyscribe"></span></a></p> </div> </div>
M templates/_footer.mustachetemplates/_footer.mustache

@@ -1,6 +1,6 @@

<footer class="sidebar"> <p><span class="h3rald"></span> Web Site v9.2.0</p> - <p>&copy; 2004&mdash;2019 &bull; <em>Fabio Cevasco</em></p> + <p>&copy; 2004&mdash;2020 &bull; <em>Fabio Cevasco</em></p> <ul class="inline"> <li><a title="email" href='&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#104;&#51;&#114;&#97;&#108;&#100;&#64;&#104;&#51;&#114;&#97;&#108;&#100;&#46;&#99;&#111;&#109;'> <i class="ent ent-mail"></i>