web.py with 1and1 shared hosting

10 views
Skip to first unread message

Mark Dowdy

unread,
Dec 31, 2017, 8:17:57 PM12/31/17
to web.py
Perhaps I don't understand what's going on in the Apache installation examples (well, I definitely don't, software development is old hat but web development is new) but I couldn't get any of them working. After more Google searches than I can count, and much teeth gnashing, I finally got the tutorial working on 1&1's shared hosting platform. In hopes of saving others some work in the future, here's my code.py file.

#!/usr/bin/env python

import wsgiref.handlers
import web

urls = (
    '/', 'index',
)

class index:
    def GET(self):
        return "Hello, world!"

if __name__ == "__main__":
    app = web.application(urls, globals())
    application = app.wsgifunc()
    wsgiref.handlers.CGIHandler().run(application)

No .htaccess file was needed. Note that this may not be appropriate for larger sites since this is serving WSGI via CGI. My site is smaller so it should be OK for me. Hope this saves someone some time in the future.

Reply all
Reply to author
Forward
0 new messages