[Ur] howto serve arbitrary files (PDF/ icons), and more
Adam Chlipala
adamc at impredicative.com
Fri Nov 5 07:51:27 EDT 2010
Marc Weber wrote:
> 1)
> Which is the ur way to serve arbitrary files such as content-type
> application/pdf ?
>
That would be the function [Basis.returnBlob].
> Eg adding "allow url css/*" to the configuration file a link to
> css/css.css complied. Status is still 404 (not found)
>
> I also tried adding path css=./css
> strace showed that urweb didn't even try to load a css.css file.
>
Ur/Web executables contain no default web server functionality for
reading from static files. I recommend hosting static content with a
traditional web server, possibly one that proxies to your application
(via HTTP or FastCGI) for the dynamic content.
> 2)
> Does urweb support the system() FFI command? If not is there a small
> example which could help getting started with exploring FFI?
>
> system could be used for many quick& dirty implementations.
>
Dirty indeed. ;) Ur/Web is designed to be completely transactional,
where any action taken can be rolled back. A general 'system' function
obviously can't satisfy this property.
If you're willing to take your chances with non-undoable commands being
run multiple times as your page handler restarts for various reasons,
you might want to start from this example:
http://www.impredicative.com/wiki/index.php/Ur_C_FFI_Example
> 3)
> How to specify the "index" file which will be used if no path is given?
>
No such functionality in Ur/Web. I again recommend using a traditional
web server or proxy for this.
More information about the Ur
mailing list