Python web infrastructure with a low barrier to entry

I am looking for the LAMPish / WAMPish experience.

Something very transparent. Write a script, press F5 and see the results. Very little if there is abstraction. SQLAlchemy and (possibly) some simple template engine will be used.

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

I do not want to write a middleware layer just to start a web service. And I do not want to deal with the specifics of CGI.

This is not intended for a very complex project, and it is intended for beginner programmers and / or beginner programmers in Python.

The complexity of MVC is out of the question. ASP.NET MVC is a well-executed IMO. The only thing I liked was that the POSTED data is automatically passed to the data model objects, if necessary.

Can you help me here?

Thanks!

PS: I did not find anything similar to these criteria in older posts.

+4
source share
7 answers

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

Features:

  • easy (dev) expand ... copy the web.py folder to the application directory, then start the server
  • display regex based url
  • very simple class mappings
  • built-in server (for most frameworks this is of course)
  • a very thin (as measured by lines of code, at least) layer on top of the python application code.

Here is his 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 Hello, World! deeply unpleasant and completely interferes with the actual demonstration of the application.

However, web.py is not perfect, and for large jobs this is probably not the right tool, because:

  • system style routes (imho) are better than pure regular expressions
  • integrating web.py with other intermediaries can be adventurous
+5
source

CherryPy may be what you need. It transparently maps URLs to Python functions and processes all cookies and session (and, of course, POST / GET parameters for you).

This is not a full stack solution like Django or Rails. On the other hand, this means that it does not compress you using a template engine or ORM that you don't like; you can use whatever you want.

It includes a WSGI compatible web server, so you donโ€™t even need Apache.

+6
source

What you most like Pylons seems to me. However, the number of web frameworks in / for Python is huge - see this page for an attempt to list and VERY briefly describe each one of them! -)

+5
source

Take a look:

  • WSGI , the standard Python API for HTTP servers for invoking Python code.
  • Django , the popular, feature-rich, well-documented Python web infrastructure.
  • web.py , a minimal Python web infrastructure
+1
source

Have you looked into the Django web frame? Its MVC framework is written in python and is relatively easy to configure and run. You can only run it with python, as it can use SQLite and its own development server, or you can configure it to use MySQL and Apache if you want.

Pylons is another framework that supports SQLAlchemy for models. I have never used it, but it seems promising.

+1
source

Do not forget the Bottle . This is a single-file micro-web structure without any dependencies and is very easy to use. Here is an example of "Hello world":

 from bottle import route, run @route('/') def index(): return 'Hello World!' run(host='localhost', port=8080) 

And here is an example of accessing POST variables (cookies and GET are similar)

 from bottle import route, request @route('/submit', method='POST') def submit(): name = request.POST.get('name', 'World') return 'Hello %s!' % name 
+1
source

Check web2py . It comes out of the box without configuration - even from a USB drive. The template language is pure Python, and you can develop the entire application through a browser editor (although I find vim faster;)

0
source

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


All Articles