Re: serving files from seaside

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

Re: serving files from seaside

jayh
Yanni Chiu wrote:

> If the question were about serving files from Squeak/Kom/Seaside,
> then there's an answer in the description for KomHttpServer at:
>    http://map.squeak.org/package/0fdb5ffc-cfa1-4d40-96c2-fe325bc8ba5f
>
> Here's the code from that page:
>
> | ma seaside |
> seaside := WAKom default.
> ma := ModuleAssembly core.
> ma serverRoot: FileDirectory default fullName.
> ma alias: '/seaside' to: [ma addPlug: [:request | seaside process:
> request]].
> ma documentRoot: FileDirectory default fullName.
> ma directoryIndex: 'index.html index.htm'.
> ma serveFiles.
> (HttpService startOn: 8080 named: 'httpd') plug: ma rootModule
>
> Also, have a look at my posting from half-an-hour prior to yours,
> about seasidehosting.st
>
> Note that it's likely that the file will be read into Squeak memory
> before being served. That may or may not be a problem.

I've been unable to successfully serve any files from Seaside.
(I've instead been saving the streams to an FTP site, and then
serving from the FTP site to get around the problem...)

The above code snippet raises more questions for me.  Does this code
have to be executed every time the contents of the directory changes
(every time a new file is produced)?   Do I need to create and update
the files "index.htm" and "index.html" to reflect the contents of the
directory?
Do I need to restart the HttpService on port 8080 every time a new file
is added to the directory.

Suppose I want to serve a MIDI file named "some.midi", which sits in the
same directory pointed to by "FileDirectory default", and then have my
Seaside
page load the file into a player as follows (having started Seaside
and executed the HTTPServer code snippet quoted above):

                fileName = 'some.midi'.
                html
                        attributeAt: 'src' put: fileName;
                        attributeAt: 'controls' put: 'true';
                        tag: 'embed'.

Which doesn't work. I just see a question mark where the player should
be.
So, should that first line instead be:
fileName = 'http://localhost:9090/some.midi'.
or
fileName = 'http://localhost:8080/some.midi'.
or
fileName = 'http://localhost:9090/seaside/some.midi'.
or
fileName = 'http://localhost:8080/seaside/some.midi'.
or
Any of the above with "httpd" instead of "http"
or
fileName = 'http://some.midi'.
or
fileName = 'httpd://some.midi'.
or
fileName = 'seaside/some.midi'

None of these seem to work.  Is it because an "index.html" file is
required (physically
located on disk at the location pointed to by "FileDirectory default")?
   Where does
the disk-based file directory intersect the file directory seen by
Seaside?
Do "FileDirectory default" and "http://localhost:9090/seaside" point to
the same
directory?

I'll admit my knowledge of networking and the web is very fragmentary,
but hopefully
there's a succinct way of accomplishing this simple operation....??

Thanks, again, for any help,
Jay





_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: serving files from seaside

Rick Zaccone
> I've been unable to successfully serve any files from Seaside.
> (I've instead been saving the streams to an FTP site, and then
> serving from the FTP site to get around the problem...)
>
> The above code snippet raises more questions for me.  Does this code
> have to be executed every time the contents of the directory changes
> (every time a new file is produced)?   Do I need to create and update
> the files "index.htm" and "index.html" to reflect the contents of  
> the directory?
> Do I need to restart the HttpService on port 8080 every time a new  
> file
> is added to the directory.
>
> Suppose I want to serve a MIDI file named "some.midi", which sits  
> in the
> same directory pointed to by "FileDirectory default", and then have  
> my Seaside
> page load the file into a player as follows (having started Seaside
> and executed the HTTPServer code snippet quoted above):
>
> fileName = 'some.midi'.
> html
> attributeAt: 'src' put: fileName;
> attributeAt: 'controls' put: 'true';
> tag: 'embed'.
>
> Which doesn't work. I just see a question mark where the player  
> should be.
> So, should that first line instead be:
> fileName = 'http://localhost:9090/some.midi'.
> or
> fileName = 'http://localhost:8080/some.midi'.
> or
> fileName = 'http://localhost:9090/seaside/some.midi'.
> or
> fileName = 'http://localhost:8080/seaside/some.midi'.
> or
> Any of the above with "httpd" instead of "http"
> or
> fileName = 'http://some.midi'.
> or
> fileName = 'httpd://some.midi'.
> or
> fileName = 'seaside/some.midi'
>
> None of these seem to work.  Is it because an "index.html" file is  
> required (physically
> located on disk at the location pointed to by "FileDirectory  
> default")?   Where does
> the disk-based file directory intersect the file directory seen by  
> Seaside?
> Do "FileDirectory default" and "http://localhost:9090/seaside"  
> point to the same
> directory?
>
> I'll admit my knowledge of networking and the web is very  
> fragmentary, but hopefully
> there's a succinct way of accomplishing this simple operation....??
>
> Thanks, again, for any help,
> Jay

Have you tried

fileName := '/some.midi'.

That is, you need to replace = with := and the file name must be  
preceded with a /.

Rick

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: serving files from seaside

jayh

Thanks very much for your suggestions - yes the "=" for assignment
operator was
just a typo, however I did try placing a "/" before the file, so the
code
now looks like:

        | fileName |
        fileName := '/some.mid'.
        html
                attributeAt: 'src' put: fileName;
                attributeAt: 'width' put: 256;
                attributeAt: 'height' put: 20;
                attributeAt: 'controls' put: 'true';
                attributeAt: 'loop' put: 'true';
                tag: 'embed'

The file "some.midi" exists in the same directory pointed to
by "FileDirectory default".  And I executed the code from
the previous post:

> | ma seaside |
> seaside := WAKom default.
> ma := ModuleAssembly core.
> ma serverRoot: FileDirectory default fullName.
> ma alias: '/seaside' to: [ma addPlug: [:request | seaside process:
> request]].
> ma documentRoot: FileDirectory default fullName.
> ma directoryIndex: 'index.html index.htm'.
> ma serveFiles.
> (HttpService startOn: 8080 named: 'httpd') plug: ma rootModule
after executing "WAKom startOn: 9090".  The rest of the Seaside pages
and
requests seem to work fine, but NOT serving the file.

Is there a simple example anywhere that isolates this functionality and
demonstrates that it works in the current version of Seaside?  We're
trying
to implement a commercial site, but this obstacle is about to convince
us
that using Smalltalk/Seaside requires more network expertise than we
possess (even though all of the the more complicated parts of the site
have
already been successfully implemented in Seaside, frustratingly
enough).


Thanks again for any pointers at all
-Jay



On Mar 20, 2006, at 1:51 PM, Rick Zaccone wrote:

> Have you tried
>
> fileName := '/some.midi'.
>
> That is, you need to replace = with := and the file name must be
> preceded with a /.
>
> Rick
>
>> I've been unable to successfully serve any files from Seaside.
>> (I've instead been saving the streams to an FTP site, and then
>> serving from the FTP site to get around the problem...)
>>
>> The above code snippet raises more questions for me.  Does this code
>> have to be executed every time the contents of the directory changes
>> (every time a new file is produced)?   Do I need to create and update
>> the files "index.htm" and "index.html" to reflect the contents of the
>> directory?
>> Do I need to restart the HttpService on port 8080 every time a new
>> file
>> is added to the directory.
>>
>> Suppose I want to serve a MIDI file named "some.midi", which sits in
>> the
>> same directory pointed to by "FileDirectory default", and then have
>> my Seaside
>> page load the file into a player as follows (having started Seaside
>> and executed the HTTPServer code snippet quoted above):
>>
>> fileName = 'some.midi'.
>> html
>> attributeAt: 'src' put: fileName;
>> attributeAt: 'controls' put: 'true';
>> tag: 'embed'.
>>
>> Which doesn't work. I just see a question mark where the player
>> should be.
>> So, should that first line instead be:
>> fileName = 'http://localhost:9090/some.midi'.
>> or
>> fileName = 'http://localhost:8080/some.midi'.
>> or
>> fileName = 'http://localhost:9090/seaside/some.midi'.
>> or
>> fileName = 'http://localhost:8080/seaside/some.midi'.
>> or
>> Any of the above with "httpd" instead of "http"
>> or
>> fileName = 'http://some.midi'.
>> or
>> fileName = 'httpd://some.midi'.
>> or
>> fileName = 'seaside/some.midi'
>>
>> None of these seem to work.  Is it because an "index.html" file is
>> required (physically
>> located on disk at the location pointed to by "FileDirectory
>> default")?   Where does
>> the disk-based file directory intersect the file directory seen by
>> Seaside?
>> Do "FileDirectory default" and "http://localhost:9090/seaside" point
>> to the same
>> directory?
>>
>> I'll admit my knowledge of networking and the web is very
>> fragmentary, but hopefully
>> there's a succinct way of accomplishing this simple operation....??
>>
>> Thanks, again, for any help,
>> Jay
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: serving files from seaside

cdavidshaffer
Jay Hardesty wrote:

>
>
> [snip]
> after executing "WAKom startOn: 9090". The rest of the Seaside pages and
> requests seem to work fine, but NOT serving the file.

This is your problem.  The code you used before started the Kom server
on port 8080.  There is no need for "WAKom startOn: 9090" since you
already have a server running serving Seaside content.  Simply access
that server on port 8080.  You can test if files are being properly
served by browsing:

http://localhost:8080/

which should show a directory listing of the root of your web server
(unless you have an index.html in place).

David

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: serving files from seaside

jayh

THANK YOU - yes - now even I understand, and it works.
Thanks for pinpointing the (current) operative gap in my
understanding - this eradicates a real frustration.

Thank you, David, and Rick.
-Jay


On Mar 21, 2006, at 12:14 AM, David Shaffer wrote:

> Jay Hardesty wrote:
>
>>
>>
>> [snip]
>> after executing "WAKom startOn: 9090". The rest of the Seaside pages
>> and
>> requests seem to work fine, but NOT serving the file.
>
> This is your problem.  The code you used before started the Kom server
> on port 8080.  There is no need for "WAKom startOn: 9090" since you
> already have a server running serving Seaside content.  Simply access
> that server on port 8080.  You can test if files are being properly
> served by browsing:
>
> http://localhost:8080/
>
> which should show a directory listing of the root of your web server
> (unless you have an index.html in place).
>
> David
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: serving files from seaside

Yanni Chiu
Jay Hardesty wrote:
>
> THANK YOU - yes - now even I understand, and it works.
> Thanks for pinpointing the (current) operative gap in my
> understanding - this eradicates a real frustration.

Here's another snippet from a previous post:
    ...
    Before you run the code above, make sure you stop WAKom and remove
    it from the startup/shutdown list, otherwise you'll get walkbacks,
    or complaints that port is already used. Some code:

WAKom stop
Smalltalk removeFromStartUpList: WAKom.
Smalltalk removeFromShutDownList: WAKom.

Since you've started WAKom in two different ways,
you may run into the same problem I did.
You'd see the problem whenever you save image,
or on restarting the image. But, you probably won't
see the problem if you keep using two different
ports (8080 & 9090).

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: serving files from seaside

jayh

Thanks - yes I did see that error - now everything seems
fine, using a single port.

I had a problem in the form of  walkbacks when
#addCookies: was being called on an HttpRequest.  Then
I found that "HttpResponse current" had somehow
been set to an HttpRequest (instead of an HttpResponse).
Clearing out "Bindings" fixed the problem.

Now everything seems to work.

Thanks again,
Jay


On Mar 21, 2006, at 1:59 AM, Yanni Chiu wrote:

> Jay Hardesty wrote:
>> THANK YOU - yes - now even I understand, and it works.
>> Thanks for pinpointing the (current) operative gap in my
>> understanding - this eradicates a real frustration.
>
> Here's another snippet from a previous post:
>    ...
>    Before you run the code above, make sure you stop WAKom and remove
>    it from the startup/shutdown list, otherwise you'll get walkbacks,
>    or complaints that port is already used. Some code:
>
> WAKom stop
> Smalltalk removeFromStartUpList: WAKom.
> Smalltalk removeFromShutDownList: WAKom.
>
> Since you've started WAKom in two different ways,
> you may run into the same problem I did.
> You'd see the problem whenever you save image,
> or on restarting the image. But, you probably won't
> see the problem if you keep using two different
> ports (8080 & 9090).
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside