Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python web framework with low barrier to entry

Tags:

python

I am looking for a LAMPish/WAMPish experience.

Something very transparent. Write the script, hit F5 and see the results. Very little, if any abstraction. SQLAlchemy and (maybe) some simple templating engine will be used.

I need simple access to the environment - similar to the PHP way. Something like the COOKIE, SESSION, POST, GET objects.

I don't want to write a middleware layer just to get some web serving up and running. And I do not want to deal with specifics of CGI.

This is not meant for a very complex project and it is for beginning programmers and/or beginning Python programmers.

An MVC framework is not out of the question. ASP.NET MVC is nicely done IMO. One thing I liked is that POSTed data is automatically cast to data model objects if so desired.

Can you help me out here?

Thanks!

PS: I did not really find anything matching these criteria in older posts.

like image 836
user51710 Avatar asked Dec 02 '22 07:12

user51710


2 Answers

CherryPy might be what you need. It transparently maps URLs onto Python functions, and handles all the cookie and session stuff (and of course the POST / GET parameters for you).

It's not a full-stack solution like Django or Rails. On the other hand, that means that it doesn't lump you with a template engine or ORM you don't like; you're free to use whatever you like.

It includes a WSGI compliant web server, so you don't even need Apache.

like image 63
Pixy Misa Avatar answered Dec 05 '22 06:12

Pixy Misa


For low barrier to entry, web.py is very very light and simple.

Features:

  • easy (dev) deploy... copy web.py folder into your app directory, then start the server
  • regex-based url mapping
  • very simple class mappings
  • built-in server (most frameworks have this of course)
  • very thin (as measured by lines of code, at least) layer over python application code.

Here is its hello world:

import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):
        if not name: 
            name = 'world'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()

As much as I like Werkzeug conceptually, writing wsgi plumbing in the Hello, World! is deeply unpleasant, and totally gets in the way of actually demoing an app.

That said, web.py isn't perfect, and for big jobs, it's probably not the right tool, since:

  • routes style systems are (imho) better than pure regex ones
  • integrating web.py with other middlewares might be adventurous
like image 34
Gregg Lind Avatar answered Dec 05 '22 06:12

Gregg Lind