Serving files with ZnServer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Serving files with ZnServer

HilaireFernandes
Hi,

On P7, I try to server files with ZnServer, but got trouble:

server := ZnServer startDefaultOn: 9595.
server delegate: (
ZnStaticFileServerDelegate new
     directory: '/home/hilaire' asFileReference ;
     prefixFromString: 'files';
     yourself).
server logToTranscript.
server start.

The browser pointed at http://localhost:9595/files/ only print:

Not Found /files/


The log reflects the not found:

2018-05-26 10:21:06 378 128292 Started ZnManagingMultiThreadedServer
HTTP port 9595
2018-05-26 10:21:10 379 552905 Connection Accepted 127.0.0.1
2018-05-26 10:21:10 380 552905 Connection Accepted 127.0.0.1
2018-05-26 10:21:10 381 990536 Request Read a ZnRequest(GET /files/) 25ms
2018-05-26 10:21:10 382 990536 Request Handled a ZnRequest(GET /files/) 4ms
2018-05-26 10:21:10 383 990536 Response Written a ZnResponse(404 Not
Found text/plain;charset=utf-8 19B) 2ms
2018-05-26 10:21:10 384 990536 GET /files/ 404 19B 6ms

Any idea?

Hilaire

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: Serving files with ZnServer

NorbertHartl
What shall it do with the directory? Did you try to access a file?

Norbert

> Am 26.05.2018 um 10:28 schrieb Hilaire <[hidden email]>:
>
> Hi,
>
> On P7, I try to server files with ZnServer, but got trouble:
>
> server := ZnServer startDefaultOn: 9595.
> server delegate: (
> ZnStaticFileServerDelegate new
>     directory: '/home/hilaire' asFileReference ;
>     prefixFromString: 'files';
>     yourself).
> server logToTranscript.
> server start.
>
> The browser pointed at http://localhost:9595/files/ only print:
>
> Not Found /files/
>
>
> The log reflects the not found:
>
> 2018-05-26 10:21:06 378 128292 Started ZnManagingMultiThreadedServer HTTP port 9595
> 2018-05-26 10:21:10 379 552905 Connection Accepted 127.0.0.1
> 2018-05-26 10:21:10 380 552905 Connection Accepted 127.0.0.1
> 2018-05-26 10:21:10 381 990536 Request Read a ZnRequest(GET /files/) 25ms
> 2018-05-26 10:21:10 382 990536 Request Handled a ZnRequest(GET /files/) 4ms
> 2018-05-26 10:21:10 383 990536 Response Written a ZnResponse(404 Not Found text/plain;charset=utf-8 19B) 2ms
> 2018-05-26 10:21:10 384 990536 GET /files/ 404 19B 6ms
>
> Any idea?
>
> Hilaire
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Serving files with ZnServer

Sven Van Caekenberghe-2
In reply to this post by HilaireFernandes
on macOS

server := ZnServer startDefaultOn: 9595.
server delegate: (
ZnStaticFileServerDelegate new
    directory: '/Users/sven/' asFileReference ;
    prefixFromString: 'files';
    yourself).
server logToTranscript.

FileLocator home / 'small.html' writeStreamDo: [ :out |
        (ZnHtmlOutputStream on: out)
                tag: #h1 with: #Small;
                tag: #p with: 'This is a small HTML document' ].
       
ZnClient new get: 'http://localhost:9595/files/small.html'.

ZnStaticFileServerDelegate does not automatically generate an index for a directory.

BTW, you do no really need to go via files, you can just serve resources directly.

> On 26 May 2018, at 10:28, Hilaire <[hidden email]> wrote:
>
> Hi,
>
> On P7, I try to server files with ZnServer, but got trouble:
>
> server := ZnServer startDefaultOn: 9595.
> server delegate: (
> ZnStaticFileServerDelegate new
>     directory: '/home/hilaire' asFileReference ;
>     prefixFromString: 'files';
>     yourself).
> server logToTranscript.
> server start.
>
> The browser pointed at http://localhost:9595/files/ only print:
>
> Not Found /files/
>
>
> The log reflects the not found:
>
> 2018-05-26 10:21:06 378 128292 Started ZnManagingMultiThreadedServer HTTP port 9595
> 2018-05-26 10:21:10 379 552905 Connection Accepted 127.0.0.1
> 2018-05-26 10:21:10 380 552905 Connection Accepted 127.0.0.1
> 2018-05-26 10:21:10 381 990536 Request Read a ZnRequest(GET /files/) 25ms
> 2018-05-26 10:21:10 382 990536 Request Handled a ZnRequest(GET /files/) 4ms
> 2018-05-26 10:21:10 383 990536 Response Written a ZnResponse(404 Not Found text/plain;charset=utf-8 19B) 2ms
> 2018-05-26 10:21:10 384 990536 GET /files/ 404 19B 6ms
>
> Any idea?
>
> Hilaire
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Serving files with ZnServer

HilaireFernandes
Le 26/05/2018 à 12:09, Sven Van Caekenberghe a écrit :
> ZnStaticFileServerDelegate does not automatically generate an index for a directory.

Ok, understood.
>
> BTW, you do no really need to go via files, you can just serve resources directly.
yes,  I was just trying.

Hilaire

--
Dr. Geo
http://drgeo.eu