7

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!

5
  • Have you looked into flask? Super lightweight framework for building webapps Commented May 2, 2012 at 10:50
  • I do not need a webapp, just a simple program that processes simple request. Commented May 2, 2012 at 10:54
  • 1
    That's pretty much what flask is. It's an interface to a wsgi server (werkzeug) and has some templating system you can ignore. Commented May 2, 2012 at 10:55
  • tkone, I actually managed to run Python with nginx from the examples and explanation in the Flask page and am now using it. Please add your comment as an answer so I can accept it. Commented May 2, 2012 at 16:01
  • answer is added. (ps the mailing list is a great place for help on flask) Commented May 2, 2012 at 16:12

4 Answers 4

8

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:

Sign up to request clarification or add additional context in comments.

2 Comments

The site appears to be dead; here is an archive link: web.archive.org/web/20170810030544/http://nichol.as/…
@DoktorJ I've updated the answer which makes the link irrelevant. It's a tad outdated anyhow :)
4

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.

1 Comment

Wow, Flask looks great! Exactly what I was looking for :)
1

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/

1 Comment

Nice solution :) It should be noted however, that using cgi is generally not really a good plan, with cgi you have to start a new process for every request which is quite slow compared to keeping the process running and letting it handle multiple requests.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.