• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 683
  • Last Modified:

python fastcgi nginx

1) To start...do not give be a link to a page unless you have done this your self nad willing to walk though unclear explanations.
2) Experience with nginx and python

I want to use fastcgi with python

not Django
not web.py
not Turbo gears.

Just a simple good old fashion cgi that prints out "Hello World"

Must have experience with python and fastcgi. and use best practice.

Thanks





0
dmontgom
Asked:
dmontgom
1 Solution
 
clockwatcherCommented:
Do you have a particular FastCGI python implementation in mind?  The newer python FastCGI implementations are WSGI compliant and expect a WSGI model app (http://www.python.org/dev/peps/pep-0333/).

Here's a barebones example nginx server config block which hands off any request coming in on port 80 to a fastcgi service running on localhost:9995.
server {
        listen 80;
        server_name  localhost;

        location / {
           fastcgi_pass localhost:9995;
           include fastcgi_params;

        }
    }

Open in new window


Here's an example of a FastCGI WSGI compliant HelloWorld app running on localhost:9995.  It uses flup to provide the FastCGI layer and WSGI compliant server.  If you have a different FastCGI implementation in mind, let us know which you want to use.
from flup.server.fcgi import WSGIServer
import cgi

def mycgi(environ, start_response):
    start_response('200 OK', [('Content-type', 'text/html')])
    form = cgi.FieldStorage( fp=environ["wsgi.input"], environ=environ)
    name = form.getfirst("name","World")
    out = "<html><body>Hello %s!</body></html>" % name
    return (out)

WSGIServer(mycgi, bindAddress=("127.0.0.1",9995)).run()

Open in new window

0
 
James MurrellProduct SpecialistCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now