Web server framework for Python web applications

I would like to receive suggestions on the best way to serve python scripts as web pages. Normally, I would like my colleagues and I to be able to write simple web pages with minimal effort, i.e. We focus on business logic, for example, creating simple forms, etc. Perhaps you can manage sessions in some way, but it's nice. It should not be WYSIWYG, as they are developers, but we are busy and do not want to spend a lot of time turning the idea into reality. This is for internal use, so performances are not of primary importance.

The software needed to enable this should be easy to configure and configure. for example, adding new directories and python lib dirs should be easy.

My first instinct is apache or tomcat with mod_python. Any comments / suggestions are welcome. Thanks in advance.

Edit - in googling I came across jython and tried this in tomcat. Pages seem to load quickly, but age is required from the command line. This may be an alternative. Write a presentation in jython servlets and save any scripts that will be used from the command line or a separate web application so that they can be run using python. Plus, like a java store, it provides a bridge to our banks. Does anyone want to talk to me from this :-)?

+7
python jython
source share
9 answers

The new WSGI standard (web server interface) and is supported by mod_wsgi for Apache.

The web server gateway interface defines a simple and universal interface between web servers and a network of applications or frameworks for the Python programming language.

The most popular Python web frameworks support WSGI ( Django , Pylons , CherryPy , ...).
These structures can help you grow your applications quickly.

You can use CherryPy for very simple applications. Here fast. What your example looks like.

+14
source share

These questions usually result in every python web frame known to man being mentioned once or twice. As Desintegr noted, wsgi is the standard interface for python web applications. However, if this is too low for your tastes, I recommend the pyramid . Here's a simple web application right from the documentation . No quick start required.

from pyramid.config import Configurator from pyramid.response import Response from paste.httpserver import serve def hello_world(request): return Response('Hello world!') def goodbye_world(request): return Response('Goodbye world!') if __name__ == '__main__': config = Configurator() config.add_view(hello_world) config.add_view(goodbye_world, name='goodbye') app = config.make_wsgi_app() serve(app, host='0.0.0.0') 

The beauty pyramid can scale well to the most complex applications , if necessary. And not self-confident, so he is very flexible.

If the pyramid is too much abstraction, I would recommend webob , which you can consider as a very subtle abstraction on top of the wsgi specification.

+7
source share

Actually, it looks like this might be a great option for a bottle :

Sample code that does something

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

Give Django a look.

From the website:

"Django is a high-level Python Web infrastructure that encourages rapid development and clean, pragmatic design."

+3
source share

Below is a list of python web frameworks here . If you are looking for something easy, this slide show compares 10 microarchimes and should be interesting.

+3
source share

You can avoid both mod_python and mod_wsgi by running Tornado (tornadoweb.org). This is a server used by a friend. So, map the class url and then create a class that defines the get () / post () methods (or any HTTP methods you want to support) and β€œjust run it” like a regular python application. Tornado is a web server and it has simple fundamentals of a very simple β€œstructure”. Check out the demos. I use django for some projects, but I also use Tornado and I think that if your application is really simple and you need to do something yesterday, the learning curve for something to happen is now not as burdensome in Tornado as this is happening with django.

However, Django has some great docs, and if you have time to learn it, then the gain is there.

0
source share

You can try Appier ( https://github.com/hivesolutions/appier ). Here is an example application:

 import appier class HelloApp(appier.App): @appier.route("/", "GET") def hello(self): return "Hello World" HelloApp().serve() 

And here is how you run it:

 pip install appier python hello.py 

Disclaimer: This structure is part of my company's open source portfolio. We built a structure to make the code for our consulting work as simple and clean as possible (to increase efficiency). The project is very active, since we use the framework all the time, but the warning is that we just started talking about it publicly recently, so that there is no community around it yet. However, for this reason, we are very open to working closely with early bird developers to improve our documentation and add new features.

0
source share

Also see pinax . It is built on top of DJango and it will give you a good start from your website.

-one
source share

You can try Spyce .

Spyce is a server-side language that supports the elegant and efficient Dynamic Generation of Python based on Python. Spyce allows you to embed Python in pages similar to how the JSP implements Java, but Spyce is much larger than the JSP Clone. Out of the box, Spyce provides development as fast as other modern frameworks such as Rails, but with a cohesive design rather than swamps for special occasions.

Spyce's modular design makes it highly flexible and extensible. It can also be used as a command line utility for preprocessing static text, or as a web server proxy.

Spyce's performance is comparable to other solutions in its class.

-one
source share

All Articles