Serving static content

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

Serving static content

Silvia Ruiz Diaz
Hi all!

I'm new to Pharo and I'm trying to generate links to be able to serve some files. This is what I have so far.


html anchor url:'http://localhost:8080/myApp/myFile'; with: 'Link'


When clicking on any of the generated links I'm getting redirected to the application homepage, so I'm wondering if is there any additional setup I have to take care of in order to grant access to these files.

My OS is Windows 64.

Thanks in advance!

Regards!
Reply | Threaded
Open this post in threaded view
|

Re: Serving static content

jtuchel
Silvia,


The URL you provide in the link points to the application, and without
any additional configuration (see below) what you see is expected behaviour.

Seaside doesn't serve files per default. There are two thing you can do

a) setup an http server like apache or nginx to serve files from some
directory and add links to that server to your application

b) implement a subclass of WAFileLibrary, import the files you want to
server from within your Smalltalk image into that FileLibrary and
register it with your application. That way your Smalltalk image works
like a classical http server for the files you added.

For both alternatives, I guess it is best to search the web, because
that would be too long a description for a mailing list. Not that they
are complicated.

Joachim

Am 26.03.15 um 00:40 schrieb Silvia Ruiz Diaz:

> Hi all!
>
> I'm new to Pharo and I'm trying to generate links to be able to serve
> some files. This is what I have so far.
>
>
> html anchor url:'http://localhost:8080/myApp/myFile'; with: 'Link'
>
>
> When clicking on any of the generated links I'm getting redirected to
> the application homepage, so I'm wondering if is there any additional
> setup I have to take care of in order to grant access to these files.
>
> My OS is Windows 64.
>
> Thanks in advance!
>
> Regards!


Reply | Threaded
Open this post in threaded view
|

Re: Serving static content

hernanmd
In reply to this post by Silvia Ruiz Diaz
Hi Silvia,

You don't need Seaside or Iliad, to serve static content. In the Configuration Browser (I guess you are using Pharo 3 at least) you can select KomHttpServer, Install, and then evaluate the following expression:

    | ma |
    ma := ModuleAssembly core.
    ma documentRoot: FileSystem disk workingDirectory fullName.
    ma directoryIndex: 'index.html index.htm'.
    ma serveFiles.
    (HttpService startOn: 8080 named: 'Example') plug: ma rootModule

Finally browse to http://localhost:8080

Cheers,

Hernán



2015-03-25 20:40 GMT-03:00 Silvia Ruiz Diaz <[hidden email]>:
Hi all!

I'm new to Pharo and I'm trying to generate links to be able to serve some files. This is what I have so far.


html anchor url:'http://localhost:8080/myApp/myFile'; with: 'Link'


When clicking on any of the generated links I'm getting redirected to the application homepage, so I'm wondering if is there any additional setup I have to take care of in order to grant access to these files.

My OS is Windows 64.

Thanks in advance!

Regards!

Reply | Threaded
Open this post in threaded view
|

Re: Serving static content

Sven Van Caekenberghe-2
Using Zinc this becomes something like:

ZnServer startDefaultOn: 1701.

ZnServer default delegate: (
  (ZnStaticFileServerDelegate new)
     prefixFromString: 'apple/macosx';
     directory: '/Library/WebServer/Documents' asFileReference;
     yourself).

http://localhost:1701/apple/macoxs/

> On 26 Mar 2015, at 06:00, Hernán Morales Durand <[hidden email]> wrote:
>
> Hi Silvia,
>
> You don't need Seaside or Iliad, to serve static content. In the Configuration Browser (I guess you are using Pharo 3 at least) you can select KomHttpServer, Install, and then evaluate the following expression:
>
>     | ma |
>     ma := ModuleAssembly core.
>     ma documentRoot: FileSystem disk workingDirectory fullName.
>     ma directoryIndex: 'index.html index.htm'.
>     ma serveFiles.
>     (HttpService startOn: 8080 named: 'Example') plug: ma rootModule
>
> Finally browse to http://localhost:8080
>
> Cheers,
>
> Hernán
>
>
>
> 2015-03-25 20:40 GMT-03:00 Silvia Ruiz Diaz <[hidden email]>:
> Hi all!
>
> I'm new to Pharo and I'm trying to generate links to be able to serve some files. This is what I have so far.
>
>
> html anchor url:'http://localhost:8080/myApp/myFile'; with: 'Link'
>
>
> When clicking on any of the generated links I'm getting redirected to the application homepage, so I'm wondering if is there any additional setup I have to take care of in order to grant access to these files.
>
> My OS is Windows 64.
>
> Thanks in advance!
>
> Regards!
>


Reply | Threaded
Open this post in threaded view
|

Re: Serving static content

Silvia Ruiz Diaz
Hi all! I wanted to thank you all for your input and suggestions. I got it to work using Zinc.

Cheers!

2015-03-26 3:32 GMT-03:00 Sven Van Caekenberghe <[hidden email]>:
Using Zinc this becomes something like:

ZnServer startDefaultOn: 1701.

ZnServer default delegate: (
  (ZnStaticFileServerDelegate new)
     prefixFromString: 'apple/macosx';
     directory: '/Library/WebServer/Documents' asFileReference;
     yourself).

http://localhost:1701/apple/macoxs/

> On 26 Mar 2015, at 06:00, Hernán Morales Durand <[hidden email]> wrote:
>
> Hi Silvia,
>
> You don't need Seaside or Iliad, to serve static content. In the Configuration Browser (I guess you are using Pharo 3 at least) you can select KomHttpServer, Install, and then evaluate the following expression:
>
>     | ma |
>     ma := ModuleAssembly core.
>     ma documentRoot: FileSystem disk workingDirectory fullName.
>     ma directoryIndex: 'index.html index.htm'.
>     ma serveFiles.
>     (HttpService startOn: 8080 named: 'Example') plug: ma rootModule
>
> Finally browse to http://localhost:8080
>
> Cheers,
>
> Hernán
>
>
>
> 2015-03-25 20:40 GMT-03:00 Silvia Ruiz Diaz <[hidden email]>:
> Hi all!
>
> I'm new to Pharo and I'm trying to generate links to be able to serve some files. This is what I have so far.
>
>
> html anchor url:'http://localhost:8080/myApp/myFile'; with: 'Link'
>
>
> When clicking on any of the generated links I'm getting redirected to the application homepage, so I'm wondering if is there any additional setup I have to take care of in order to grant access to these files.
>
> My OS is Windows 64.
>
> Thanks in advance!
>
> Regards!
>