Hello! (my apologies if this is duplicate - previous email
didn't seem
to go through)
I am just trying to get savvy with CherryPy and trying to
work
through some of
the tutorials and create a simple application. I am trying
to get a
directory set
up to serve static content out of, and can't seem to get it
to work.
The example
I am trying to follow is here: http://cherryp
y.org/wiki/StaticContent
My configuration file is as follows, which I think is
funcitonally the
same as the
example.
[global]
server.socket_port = 8088
server.thread_pool = 10
server.environment = "production"
tools.sessions.on = True
# server.showTracebacks = True
# server.logToScreen = False
[/]
tools.staticdir.root =
"/home/ej/proj/calibration_pages"
[/static]
tools.staticdir.on = True
tools.staticdir.dir = "static"
I'm confident my server is actually reading the file,
because I can see
that
it starts on the port specified (as well as restarts if you
edit the
file while its running) but when I try to call a url such
as:
http://localho
st:8088/static/login.css
the server prints out:
192.168.0.135 - - [17/Oct/2006:14:00:47] "GET
/static/login.css
HTTP/1.1"
404 1065 "" "Mozilla/5.0 (Windows; U; Windows
NT 5.0; en-US;
rv:1.8.0.6)
Gecko/20060728 Firefox/1.5.0.6"
The file is actually there...
ej mako:~/proj/calibration_pages> pwd
/home/ej/proj/calibration_pages
ej mako:~/proj/calibration_pages> ls -ld static
drwxr-xr-x 2 ej users 80 2006-10-17 11:09 static
ej mako:~/proj/calibration_pages> ls -l static
total 4
-rwxr-xr-x 1 ej users 1553 2006-09-12 18:26 login.css
So... I guess I am missing something, but I don't see it.
Anyone see
what's
wrong here?
Thanks! ;)
-ej
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at ht
tp://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
http://groups-beta.googl
e.com/group/cherrypy-users/browse_thread/thread/36c4b798c1b1
364a
On Oct 17, 1:33 pm, "ej" <ejohn... earthlink.net> wrote:
> Hello! (my apologies if this is duplicate - previous
email didn't seem
> to go through)
>
> I am just trying to get savvy with CherryPy and
trying to work
> through some of
> the tutorials and create a simple application. I am
trying to get a
> directory set
> up to serve static content out of, and can't seem to
get it to work.
> The example
> I am trying to follow is here: http://cherryp
y.org/wiki/StaticContent
>
> My configuration file is as follows, which I think is
funcitonally the
> same as the
> example.
>
> [global]
> server.socket_port = 8088
> server.thread_pool = 10
> server.environment = "production"
> tools.sessions.on = True
> # server.showTracebacks = True
> # server.logToScreen = False
>
> [/]
> tools.staticdir.root =
"/home/ej/proj/calibration_pages"
>
> [/static]
> tools.staticdir.on = True
> tools.staticdir.dir = "static"
>
> I'm confident my server is actually reading the file,
because I can see
> that
> it starts on the port specified (as well as restarts if
you edit the
> file while its running) but when I try to call a url
such as:http://localho
st:8088/static/login.css
>
> the server prints out:
>
> 192.168.0.135 - - [17/Oct/2006:14:00:47] "GET
/static/login.css
> HTTP/1.1"
> 404 1065 "" "Mozilla/5.0 (Windows; U;
Windows NT 5.0; en-US;
> rv:1.8.0.6)
> Gecko/20060728 Firefox/1.5.0.6"
>
> The file is actually there...
> ej mako:~/proj/calibration_pages> pwd
> /home/ej/proj/calibration_pages
> ej mako:~/proj/calibration_pages> ls -ld static
> drwxr-xr-x 2 ej users 80 2006-10-17 11:09 static
> ej mako:~/proj/calibration_pages> ls -l static
> total 4
> -rwxr-xr-x 1 ej users 1553 2006-09-12 18:26 login.css
>
> So... I guess I am missing something, but I don't see
it. Anyone see
> what's
> wrong here?
>
> Thanks! ;)
> -ej
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at ht
tp://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
On Oct 20, 4:19 am, "Sutabi" <sut... gmail.com> wrote:
> http://groups-beta.google.com/group/cher
rypy-users/browse_thread/thre...
OK, well... either something is still not working right, or
I am not
understanding something about the quickstart() method. I
have an added
complication in that port 8080 is in use by Apache, so I
need to
specify a different port to run on. For the record, I am
running
CherryPy-3.0.0beta2
First of all, the following file (slightly modified from
Christian's
example - no decorators in Python 2.3.4 ) does what I would
expect
(that is, I can call URL's such as http://machine:808
8/static/bar.txt
and get the file contents of anything in that directory
served up (and
the given link from index works too)):
#-----------------------------------------------------------
------------
#!/usr/bin/env python
import cherrypy
class MyFiles(object):
def index(self):
return """
<html>
<head><title>foo.txt</title></head>
<body>
<a href='/static/foo.txt'>foo.txt</a>
</body>
</html>
"""
index.exposed = True
cherrypy.config.update(
{ 'server.socket_port' : 8088,
'tools.staticdir.root' :
'/home/ej/proj/calibration_pages',
}
)
appconfig = {
'/static' : { 'tools.staticdir.on' : True,
'tools.staticdir.dir' : 'static',
},
}
cherrypy.quickstart(MyFiles(), config=appconfig)
# EOF
#-----------------------------------------------------------
------------
Trying to go to Christian's example with a config file, this
code does
not start a server on port 8088 as I would expect, and
naturally dumps
a stack trace saying port 8080 is in use:
ej mako:~/proj/calibration_pages> cat static2.conf
[global]
server.socket_port = 8088
[/static]
tools.staticdir.on = True
tools.staticdir.dir =
"/home/ej/proj/calibration_pages/static"
ej mako:~/proj/calibration_pages> cat static2.py
#!/usr/bin/env python
import cherrypy
class MyFiles(object):
def index(self):
return """
<html>
<head><title>foo.txt</title></head>
<body>
<a href='/static/foo.txt'>foo.txt</a>
</body>
</html>
"""
index.exposed = True
# cherrypy.config.update('static2.conf')
# cherrypy.quickstart(MyFiles())
cherrypy.quickstart(MyFiles(), config='static2.conf')
ej mako:~/proj/calibration_pages> ./static2.py
[20/Oct/2006:11:24:15] HTTP Port 8080 not free on
'localhost'
Traceback (most recent call last):
File "./static2.py", line 20, in ?
cherrypy.quickstart(MyFiles(), config='static2.conf')
File
"/usr/home/ej/CherryPy-3.0.0beta2/cherrypy/__init__.py&
quot;, line
28, in quickstart
server.quickstart()
File
"/usr/home/ej/CherryPy-3.0.0beta2/cherrypy/_cpserver.py
", line
69, in quickstart
self.start()
File
"/usr/home/ej/CherryPy-3.0.0beta2/cherrypy/_cpserver.py
", line
97, in start
self._start_http(httpserver)
File
"/usr/home/ej/CherryPy-3.0.0beta2/cherrypy/_cpserver.py
", line
106, in _start_http
wait_for_free_port(*bind_addr)
File
"/usr/home/ej/CherryPy-3.0.0beta2/cherrypy/_cpserver.py
", line
224, in wait_for_free_port
raise IOError(msg)
IOError: Port 8080 not free on 'localhost'
ej mako:~/proj/calibration_pages>
OK, if I change the file to run the other two lines that
were
previously commented...
ej mako:~/proj/calibration_pages> vi static2.py
ej mako:~/proj/calibration_pages> cat static2.py
#!/usr/bin/env python
import cherrypy
class MyFiles(object):
def index(self):
return """
<html>
<head><title>foo.txt</title></head>
<body>
<a href='/static/foo.txt'>foo.txt</a>
</body>
</html>
"""
index.exposed = True
cherrypy.config.update('static2.conf')
cherrypy.quickstart(MyFiles())
# cherrypy.quickstart(MyFiles(), config='static2.conf')
The server now runs...
ej mako:~/proj/calibration_pages> ./static2.py
[20/Oct/2006:11:25:44] HTTP Serving HTTP on http://localhost:8088/
But static content doesn't get served. More explicitly:
http://mako:8088/
begets:
192.168.0.135 - - [20/Oct/2006:11:27:37] "GET /
HTTP/1.1" 200 114 ""
"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;
rv:1.8.0.6)
Gecko/20060728 Firefox/1.5.0.6"
that is, the web page (index) you would expect gets served,
but if you
click on the link, the server prints this:
192.168.0.135 - - [20/Oct/2006:11:27:43] "GET
/static/foo.txt HTTP/1.1"
404 1061 "http://mako:8088/"
"Mozilla/5.0 (Windows; U; Windows NT 5.0;
en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6"
and you get a 404 error formatted in your browser.
So, first of all, it seems to me that these two lines:
cherrypy.config.update('static2.conf')
cherrypy.quickstart(MyFiles())
should be functionally equivalent to this line:
cherrypy.quickstart(MyFiles(), config='static2.conf')
They are not. Is it your expectation that they would be, or
am I
misunderstanding something?
Christian's example without config file specifies
tools.staticdir.root and then specifies tools.staticdir.dir
as a
relative path, but his example with a config file doesn't
specify
tools.staticdir.root and then gives an absolute path for
tools.statdir.dir. This makes sense to me. So, given that
those should
be equivalent, it is my expectation that this code:
cherrypy.config.update(
{ 'server.socket_port' : 8088,
'tools.staticdir.root' :
'/home/ej/proj/calibration_pages',
}
)
appconfig = {
'/static' : { 'tools.staticdir.on' : True,
'tools.staticdir.dir' : 'static',
},
}
cherrypy.quickstart(MyFiles(), config=appconfig)
Should give the same behavior as this code:
cherrypy.config.update('static2.conf')
cherrypy.quickstart(MyFiles())
when static2.conf has this text:
[global]
server.socket_port = 8088
[/static]
tools.staticdir.on = True
tools.staticdir.dir =
"/home/ej/proj/calibration_pages/static"
It does not. It seems to me that something is fishy in
parsing and
using config files. Is it also your expectation that these
would be
equivalent, or am I misunderstanding something?
Thanks for any contributed help,
-ej
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at ht
tp://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|