Solved

python fastcgi nginx

Posted on 2011-03-12
3
598 Views
Last Modified: 2012-05-11
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
Comment
Question by:dmontgom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 35154016
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
 
LVL 31

Expert Comment

by:James Murrell
ID: 36515796
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question