@Christian

I'm so sorry. I don't know how this sneaked into the code and especially how I could overlook it for two hours this morning.
Maybe because of Friday ...
Of course it works as it should. Thanks.

@Felix

Yes your pattern sounds meaningful and I often used the approach. Nowadays I'm working on a project that is a small web wrapper on some sort of embedded machine and I have to pay attention to disk usage, amount of processes and so on. Thus, no extra webserver this time.
Thanks.

Best Regards,
Marco.

On 06/05/2016 17:55, Felix Wolf wrote:
Hi Marco,

my preferred setup is to use a reverse proxy in front of basex.
This would allow you beside other advantages to completely free basex from serving static files.
Famous http servers like Apache or NGINX could act as reverse proxies.

This is a sample NGINX configuration snippet:

        location ~* ^.+\.(jpg|jpeg|gif|png|css|pdf|js|flv|swf|html|htm)$
        {
                root   /home/basex/webapp;
        }

        location / {
                proxy_pass http://127.0.0.1:8984;
        }

I hope this will be no contrifusion :)

Felix


Am 06.05.2016 um 17:23 schrieb Christian Grün:
Hi Marco,

Does the behavior change if you remove output:method("html")?

Cheers,
Christian


declare
   %rest:path("/dasbox/ui/resources/{$resource=.+}")
   %rest:GET
   %output:method("html")
function ui:resources($resource as xs:string){
   let $path := file:base-dir() || 'resources/' || $resource
   let $mediatype := web:content-type($path)
   return (
     web:response-header(map { 'media-type': $mediatype }),
     if (matches($mediatype, "^text/.+")) then file:read-text($path)
     else file:read-binary($path)
   )
};

Thanks for your support,
Marco.


On 03/05/2016 02:59, Murray, Gregory wrote:
Hi Christian,

Thanks for the hints! I see that using webapp/static does work, but I
prefer to keep all files related to an app together under one directory, so
I'll use the second option you provided -- using RESTXQ.

Many thanks,
Greg

________________________________________
From: Christian Grün [christian.gr...@gmail.com]
Sent: Monday, May 02, 2016 3:20 AM
To: Murray, Gregory
Cc: basex-talk@mailman.uni-konstanz.de
Subject: Re: [basex-talk] Web application static files

Hi Greg,

Thanks for your mail. If you are working with the ZIP distribution,
you could compare your code with the RESTXQ examples in the restxq.xqm
file.

I assume you get 404 because your static directory is a sub-directory
of bookplates. Here are two things you can do:

* Move your static directory from "webapp/bookplates" to "webapp"
* Deliver static files via RESTXQ (see common.xqm and the REST path
"/dba/static/{$file=.+}").

Does this help?
Christian



On Sun, May 1, 2016 at 6:43 PM, Murray, Gregory
<gregory.mur...@ptsem.edu> wrote:
Hello,

I'm new to BaseX, and I'm setting up a simple web application (on
Mac/Unix, using the ZIP distribution of BaseX). I'm unable to bring in
static files like CSS. Following the documentation and the "dba" web
application that comes with BaseX, I have included the following in the
HTML:

<link rel="stylesheet" type="text/css" href="static/app.css"/>

to point to a file that resides here:

~/basex/webapp/bookplates/static/app.css

I have a module sitting here:

~/basex/webapp/bookplates/controller.xqm

with a function with these annotations:

%rest:path("bookplates")
%output:method("html")

When I point my browser to http://localhost:8984/bookplates/ the server successfully returns the HTML, but when the browser tries to load the CSS it requests http://localhost:8984/bookplates/static/app.css and the server responds with a 404 saying "No function found that matches the request" as
if the server is looking for a RESTXQ function.

What am I doing wrong?

Thanks,
Greg



Reply via email to