[newbie] My very first python web app (no framework)

scardig at gmail.com scardig at gmail.com
Sun Dec 9 09:43:06 EST 2007


This is my first Python web pseudo-app: "you give me some data, I give
you func(data)". I'm on a shared host with mod_fastcgi so I installed
a virtual python environment + flup (no middleware now, just wsgi
server).

========= dispatch.fcgi =================
from fcgi import WSGIServer
import sys, cgi, cgitb,os
import myfunctions

def myapp(environ, start_response):
	start_response('200 OK', [('Content-Type', 'text/html')])
        write = []
        write.append (myfunctions.func1(par1,par2))
        write.append (myfunctions.func2(par1,par2))
        # [...]
        write.append (myfunctions.funcn(par1,par2))
	return [write]

if __name__=="__main__":
	WSGIServer(myapp).run()
====================================

====== myfunctions.py ==================
def func1(a,b):
    return a
def func2(a,b):
    return b
====================================

Is it the right way to go? Is it safe in a web production
environment ? Is it thread-friendly (since flup is threaded) ?

tnx




More information about the Python-list mailing list