Getting web.py running on IIS
![]()
Image via Wikipedia
web.py is a great super light weight framework if you need to get a fast site up that uses python on the backend to process a lot of data. There are plenty of other options like pylons or django or just using python’s cgi scripts but I wanted something that I can throw up, make a lot of reports, paste in different sql from different ms sql tables and make a handful of reporting templates to throw together a few different configurations of this data and web.py seemed like a good solution because there’s no command line builds of scaffolding ala rails or django and you aren’t tied (or necessarily encouraged) to use native ORM’s if you already have the sql ready to go. It does however have a robust python based native templating engine and language that’s really easy to learn and the url routing is increadibly easy and logical so you can make a few different pages or a few different apps and get all of the view templating of rails or django but not all of the forced structure.
One problem. It doesn’t easily run in a CGI bin or on Windows IIS which my company uses. It’s ready to go on Apache or lighttpd or nginx. I figured out how to do this using a discussion here.
1. configure IIS to run python and .py files
2. install web.py on your server. download here. command line ‘setup.py install’
3. put flup on your server. download here. and don’t install it yet….
4. find fcgi_base.py in that flup package and in it comment out this block of code…like this:
#sock = socket.fromfd(FCGI_LISTENSOCK_FILENO, socket.AF_INET,
# socket.SOCK_STREAM)
# try:
# sock.getpeername()
# except socket.error, e:
# if e[0] == errno.ENOTSOCK:
# Not a socket, assume CGI context.
# isFCGI = False
# elif e[0] != errno.ENOTCONN:
# raise
5. then above it you’ll see isFCGI = True. change that to isFCGI = False
6. then go back to the flup directory and run ‘setup.py install’ from the command line.
7. then drop your app in a CGI enabled folder on IIS and you should be good to go.
Only catch is your urls will have a root of http://server/app/app.py/ and in your app for the urls variable it will look like this or a variation of this:
urls = (
'/app/app.py(.*)', 'index'
)
I’m new at this stuff so if I missed anything, feel free to chime in but this is not documented in webpy.org and it took me about a week to figure out so I figured I’d post it.
- Comparing Python frameworks: A simple webapp in Flask, web.py, bottle, juno … (agiliq.com)
- Term Extraction | fivefilters.org (fivefilters.org)
- Welcome to Web2py Utils’s documentation! - Web2py Utils v0.0.13-alpha documentation (packages.python.org)
