gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] 24/49: examples/web: Put different information on separa


From: gnunet
Subject: [gnunet-scheme] 24/49: examples/web: Put different information on separate pages.
Date: Sat, 25 Dec 2021 23:00:01 +0100

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a commit to branch master
in repository gnunet-scheme.

commit 1abaf10fe083e522a05086524f2378124b07ae53
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Sep 25 21:55:42 2021 +0200

    examples/web: Put different information on separate pages.
    
    * examples/web.scm (url-handle): Create separate "/",
      "/network-size", "/search-dht" and "/put-dht" pages.
---
 examples/web.scm | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/examples/web.scm b/examples/web.scm
index f51d621..94af733 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -19,7 +19,10 @@
              #:prefix #{dht:}#)
             (web response)
             (web server)
+            (web uri)
+            (web request)
             (srfi srfi-11)
+            (ice-9 match)
             (sxml simple))
 
 (define config (load-configuration))
@@ -82,12 +85,22 @@
        (dd ,(number->string (nse:estimate:standard-deviation estimate)))))
 
 (define (url-handler server request body)
-  (define current-estimate (nse:estimate server))
-  (define estimate-text
-    (if current-estimate
-       (estimate->html current-estimate)
-       '(p "No estimate yet")))
-  (respond/html `(div ,estimate-text ,search-form ,put-form)))
+  (pk 'r request body)
+  (match (uri-path (request-uri request))
+    ("/" (respond/html
+         `(div (p "A few links")
+               (ul (li (a (@ (href "/network-size")) "network size"))
+                   (li (a (@ (href "/search-dht")) "search the DHT")
+                       (li (a (@ (href "/put-dht")) "add things to the 
DHT")))))))
+    ("/network-size"
+     (respond/html
+      (let ((current-estimate (nse:estimate server)))
+       (if current-estimate
+           (estimate->html current-estimate)
+           '(p "No etimate yet")))))
+    ("/search-dht" (respond/html search-form))
+    ("/put-dht" (respond/html put-form))
+    (_ (respond/html '(p "not found"))))) ; TODO 404
 
 (define (start config)
   (define nse-server (nse:connect config))

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]