开发者

Apache2: mod_wsgi or mod_python, which one is better?

开发者 https://www.devze.com 2022-12-23 00:52 出处:网络
I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred?

I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred?

Thank you

Bala

Update

I am still confused. Please help.

Better in my sense means:

1. Bug will be fixed periodically.

2. Chosen by most developers.

3. Additional features like authentication tokens like AWS, can be supported out of the box.

4. No strong dependency on version.( I see that wsgi requires python 2.6)

5. All python libraries will work out of the box.

6. Scalable in the future.

7. Future upgrade don't cause any issues.

With my limited experience, I want these features. There might be some I might be missing.

Thanks

Bala

Update

I am sorry for all the confusion caused. I just want to expose a restful w开发者_StackOverfloweb services in python language. Is there a good framework?


mod_wsgi is more actively maintained and (I hear -- haven't benchmarked them myself!) better performing than mod_python. So unless you need exclusive features of mod_python, just to use a web app framework (or non-framework, like werkzeug;-), you're probably better off with mod_wsgi! (Just about every Python web framework, and many non-frameworks of which werkzeug is my favorite, support WSGI as their standard interface to the web server, these days).


Don't confuse what WSGI and mod_wsgi are. WSGI is an interface specification for hosting Python web applications on a server. The mod_wsgi module is an implementation of the WSGI specification using Apache as the underlying web server. Thus, Python and WSGI are not choices exactly, WSGI is just one way of being able to communicate between a Python web service/application and the web server. The mod_wsgi package is one implementation of that interface. So, WSGI is a means to an end, not a solution in itself.

Personally, I'd very much suggest you just use a minimal Python framework/non framework and as Alex suggests, Werkzeug is a good choice.


If you just want to run web apps then use mod_wsgi. If you need to write a handler for the rest of httpd's request/response phases then use mod_python.


mod_wsgi is specifically tuned to run Python web apps that use WSGI in Apache. mod_python is for any kind of Python web app, including WSGI apps. mod_wsgi also has a lower memory footprint than mod_python.


mod_wsgi is much more actively maintained than mod_python at this point. It also has a good bit of momentum, as it was somewhat recently adopted as the preferred deployment method on apache2 by Django. The author is also actively engaged with the Python community in regards to the future evolution of WSGI.


  1. Bug will be fixed periodically.

    Unless you're paying money, you cannot have any idea about this.

  2. Chosen by most developers.

    mod_wsgi

  3. Additional features like authentication tokens like AWS, can be supported out of the box.

    True for every framework.

  4. No strong dependency on version.( I see that wsgi requires python 2.6)

    What? Everything depends on compatible versions. Everything. Every single piece of software.

  5. All python libraries will work out of the box.

    "All?" What about the poorly-written ones?

  6. Scalable in the future.

    Sure. We always hope for this. There's no guarantee.

  7. Future upgrade don't cause any issues.

    That's funny.

"I want these features."

We all do. Realistically, you can get #2. The rest don't make sense or cannot every be assured.

0

精彩评论

暂无评论...
验证码 换一张
取 消