login community faq

As my forum title says above, I am not able to get web.py running under lighttpd fastcgi. Static files are returning fine, but request for the python code just downloads the file source code.

Here's my web.py python code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/local/bin/python2.7
from flup.server.fcgi import WSGIServer
import web

urls = (
    '/.*', 'home',
    '/me', 'me'
)

class home:
    def GET(self):
        return 'this is the home page'

class me:
    def GET(self):
        return 'this is my page'

app = web.application(urls, globals())

web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)

if __name__ == "__main__":
    app.run()

Here's my fastcgi config file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
server.document-root = "/home/neorou73/webapps/fastcgi1/pages"
server.port          = 32053
server.modules       = ( "mod_accesslog", "mod_rewrite", "mod_fastcgi" )
accesslog.filename   = "/home/neorou73/webapps/fastcgi1/access.log"
server.errorlog      = "/home/neorou73/webapps/fastcgi1/error.log"
fastcgi.debug        = 1
fastcgi.map-extensions = (".py" => ".py")
fastcgi.server       = ( "/code.py" =>
                       ( "/" =>
                           ( "socket" => "/home/neorou73/webapps/fastcgi1/pages/app/fastcgi.python.sock",
                             "bin-path" => "/home/neorou73/webapps/fastcgi1/pages/app/code.py",
                             "max-procs" => 1,
                             "bin-environment" => (
                                 "REAL_SCRIPT_NAME" => ""
                                 ),
                             "check-local" => "disable"
                           )
                        )
                   )

mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"
)

Can somebody help me figure out what is wrong? Please do not advise me to use a different platform because it is easier. I got web.py working at home, have a bunch of code I would like to use for production, but I can not seem to get it to work properly on this host.

Thanks in advance...

asked Aug 07 '12 at 09:20

neorou73's gravatar image

neorou73
32


Since we do not use lighttp normally I can't be sure without testing, but I think it is these lines,

1
2
fastcgi.server       = ( "/code.py" =>
                         "bin-path" => "/home/neorou73/webapps/fastcgi1/pages/app/code.py",

Try this,

1
2
fastcgi.server       = ( ".py" =>
                         "bin-path" => "code.py",

Their documentation shows a basic example and includes a forum thread which explains it.

answered Aug 07 '12 at 17:40

johns's gravatar image

johns ♦♦
340427

Thanks, johns. the python code is being accessed properly, but the server simply returns the file as a download, and not pass it through the fastcgi processor.

(Aug 09 '12 at 09:53) neorou73 neorou73's gravatar image

Hi,

Have you tried doing the change my colleague suggested, and restarting lighthttpd after that? I suggest that you also try adding this line:

1
   "fix-root-scriptname" => "enable",

(after the "check-local" => "disable" line) Make sure you restart lighthttpd after you make any such change.

(Aug 10 '12 at 02:13) todork todork's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×9
×3

Asked: Aug 07 '12 at 09:20

Seen: 563 times

Last updated: Aug 10 '12 at 02:13

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited