Python-fastcgi extension

There is not much documentation related to the python-fastcgi C library, so I'm wondering if anyone can provide a simple example of how to make a simple FastCGI server with it. An example of "Hello World" would be great.

+3
source share
2 answers

Edit: I misunderstood the question. By email Oh.

Jon Python Modules is a collection of useful modules and includes the excellent FastCGI module: http://jonpy.sourceforge.net/fcgi.html

Here is an example from the page:

import jon.cgi as cgi 
import jon.fcgi as fcgi

class Handler(cgi.Handler):
  def process(self, req):
    req.set_header("Content-Type", "text/plain")
    req.write("Hello, world!\n")

fcgi.Server({fcgi.FCGI_RESPONDER: Handler}).run()
+4
source

fastcgi WSGI, ​​ , fastcgi .

test.fgi, :

#!/usr/bin/env python

from fcgi import WSGIServer

def app(env, start):

    start('200 OK', [('Content-Type', 'text/plain')])
    yield 'Hello, World!\n'
    yield '\n'

    yield 'Your environment is:\n'
    for k, v in sorted(env.items()):
        yield '\t%s: %r\n' % (k, v)

WSGIServer(app).run()
+3

Source: https://habr.com/ru/post/1708528/


All Articles