ddinchev
ddinchev

Reputation: 34673

How to run nginx + python (without django)

I want to have simple program in python that can process different requests (POST, GET, MULTIPART-FORMDATA). I don't want to use a complete framework.

I basically need to be able to get GET and POST params - probably (but not necessarily) in a way similar to PHP. To get some other SERVER variables like REQUEST_URI, QUERY, etc.

I have installed nginx successfully, but I've failed to find a good example on how to do the rest. So a simple tutorial or any directions and ideas on how to setup nginx to run certain python process for certain virtual host would be most welcome!

Upvotes: 7

Views: 7689

Answers (4)

Wolph
Wolph

Reputation: 80031

Although you can make Python run a webserver by itself with wsgiref, I would recommend using one of the many Python webservers and/or web frameworks around. For pure and simple Python webhosting we have several options available:

If you're looking for more features you can look at some web frameworks:

Upvotes: 8

tkone
tkone

Reputation: 22728

You should look into using Flask -- it's an extremely lightweight interface to a WSGI server (werkzeug) which also includes a templating library, should you ever want to use one. But you can totally ignore it if you'd like.

Upvotes: 4

tapan
tapan

Reputation: 1796

You can use thttpd. It is a lightweight wsgi server for running cgi scripts. It works well with nginx. How to setup thttpd with Nginx is detailed here: http://nginxlibrary.com/running-cgi-scripts-using-thttpd/

Upvotes: 1

Denis
Denis

Reputation: 7343

All the same you must use wsgi server, as nginx does not support fully this protocol.

Upvotes: 0

Related Questions