Creating a simple python web application

AlpU picture AlpU · Aug 10, 2016 · Viewed 26.1k times · Source

I have a python script that takes inputs from commandline. I simply want to modify this script so I can run it on web. I want the commandline interface to be replaced by a simple boxes in a web page, and once the script is executed, I want the results to be shown on a webpage like it does in commandline.

Any help on where to start, which python packages to use and which steps to take would be much appreciated.

Until now, I read a little about webapp2 for Google App Engine and web.py. I do not want to use Django.

Thank you!

Answer

FaureHu picture FaureHu · Aug 10, 2016

While you can use a microframework like Flask [1] for quickly getting started, you can get closer to the metal. Try learning about the HTTP protocol and implement your own server using the http module. Python 3's http.server contains a class SimpleHTTPServer [2] which can be very good for understanding how you're communicating between the client and your process.

[1] http://flask.pocoo.org/docs/0.12/quickstart/

[2] https://docs.python.org/2/library/simplehttpserver.html