... does not contain WSGI application '/var/www/mod_wsgi_test.py::application'

1,862 views
Skip to first unread message

gregp...@gmail.com

unread,
Oct 13, 2007, 12:15:26 AM10/13/07
to modwsgi
I was about to send the message below and then I figured out the
answer. I figured I'll still send it though so the answer is
documented for people like me who search before reading
documentation :-(

ANSWER:
The WSGI application contained within the code file should be called
"application". Mine was called "simple_app" to start. (It's in the
readme file)


QUESTION:

I'm trying to set up mod_wsgi with a test application but I'm getting
a 404 not found error: "The requested URL / was not found on this
server.", and the log file says:

[Fri Oct 12 23:48:55 2007] [error] [client 69.255.191.154] mod_wsgi
(pid=15437): Target WSGI script '/var/www/mod_wsgi_test.py' does not
contain WSGI application '/var/www/mod_wsgi_test.py::application'.

I'm on Ubuntu 7.04 with Apache/2.2.3, mod_wsgi/1.1, and Python/
2.5.1c1

Thanks,

-Greg


Here's how I set things up:

/etc/apache2/httpd.conf
------------------------------------
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

/etc/apache2/sites-available/default
------------------------------------
NameVirtualHost *
<VirtualHost *>
ServerAdmin xxx...@gmail.com
DocumentRoot /var/www/
WSGIScriptAlias / /var/www/mod_wsgi_test.py
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
AllowOverride None
Order allow,deny
allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error,
crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

/var/www/mod_wsgi_test.py
---------------------------------------
#! /usr/bin/env python2.5

def simple_app(environ, start_response):
"""Simplest possible application object"""
status = '200 OK'
response_headers = [('Content-type','text/plain')]
start_response(status, response_headers)
return ['Hello world!\n']

Ben Hoyt

unread,
Oct 13, 2007, 3:51:28 AM10/13/07
to mod...@googlegroups.com
Hi Greg, good going. :-)

Alternatively, you can specify whatever function to call you want. (Though it's probably better practice to rename it "application" as you've done.) Just use the WSGICallableObject directive in your Apache config, like so:

    WSGICallableObject simple_app

Search for help on the WSGICallableObject here:
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives

Graham, I don't suppose there's any way with the Google Code wikis to give each section an HTML id= attribute? So that you can just go to a specific section with something like the following?

http://.../modwsgi/wiki/ConfigurationDirectives#WSGICallableObject

-Ben



On 10/13/07, gregp...@gmail.com <gregp...@gmail.com > wrote:

I was about to send the message below and then I figured out the
answer.  I figured I'll still send it though so the answer is
documented for people like me who search before reading
documentation :-(

ANSWER:
The WSGI application contained within the code file should be called
"application".  Mine was called "simple_app" to start. (It's in the
readme file)


--
Ben Hoyt, +64 21 331 841
http://www.benhoyt.com/

Graham Dumpleton

unread,
Oct 13, 2007, 4:02:33 AM10/13/07
to mod...@googlegroups.com
On 13/10/2007, Ben Hoyt <ben...@gmail.com> wrote:
> Graham, I don't suppose there's any way with the Google Code wikis to give
> each section an HTML id= attribute? So that you can just go to a specific
> section with something like the following?
>
> http://.../modwsgi/wiki/ConfigurationDirectives#WSGICallableObject

Not at present

It is down for being implemented in 2007 though.

http://code.google.com/p/support/issues/detail?id=376

Graham

Reply all
Reply to author
Forward
0 new messages