In the second case, #:servlet-regexp #rx""
makes it so that `start` gets first dibs on all requests. Your dispatch function includes an `else` case, so anything that doesn't match an explicit case is handled. If you remove the `else`, then things not explicitly mentioned will have (next-dispatcher) called which will go to the static handler. Or, if you really want else, you could add something like (define (static req) (next-dispatcher)) .... [("static" str-arg ...) static] .... And make static stuff explicit. But I recommend removing else. Jay On Tue, Jan 5, 2016 at 5:25 AM, pvt <liweijian.h...@gmail.com> wrote: > I want to show some images, if I have only one application, the image could > be showed in the web paged as expected: > > ```scheme > > #lang racket > > (require web-server/servlet) > (require web-server/servlet-env) > > (define (my-app req) > (response/xexpr > '(html (head (title "OK")) > (body (h1 "ok now") > (img ((src "/large.png"))))))) > > (serve/servlet my-app > #:launch-browser? #t > #:quit? #f > #:listen-ip #f > #:port 8080 > #:extra-files-paths (list (build-path (current-directory) > "htdocs")) > #:servlet-path "/") > > ``` > > However, if I add another application, the image now could not be shown by > visiting: >> http://localhost:8080/myapp > > > ```scheme > > #lang racket > > (require web-server/servlet) > (require web-server/servlet-env) > > (define (start request) > (dispatch request)) > > (define-values (dispatch url) > (dispatch-rules > (("") list-domains) > (("myapp") my-app) > (else list-domains))) > > (define (my-app req) > (response/xexpr > '(html (head (title "OK")) > (body (h1 "ok now") > (img ((src "/large.png"))))))) > > (define (list-domains req) > (response/xexpr > '(html (head (title "hi")) > (body (p "continue..."))))) > > (serve/servlet start > #:launch-browser? #t > #:quit? #f > #:listen-ip #f > #:port 8080 > #:servlet-path "/" > #:extra-files-paths (list (build-path (current-directory) > "htdocs")) > #:servlet-regexp #rx"") > > ``` > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Jay McCarthy Associate Professor PLT @ CS @ UMass Lowell http://jeapostrophe.github.io "Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great." - D&C 64:33 -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.