Search code examples
pythoncgiwebapi

Python CGI with API


I am quite new to Python, I have built some applications in Python with CGI and I found cgi is much easier compare to a framework as I have full control on everything. Tried to build a web API through below module but it end up with a web page rather than an API.

import cgi
import cgitb

I would like to create a web API, as I am familiar with cgi I would like to create it (web API) through python cgi,I have been looking for a good documentation but I didn't find any. It would be helpful if someone can give me a clue. I really appreciate your help.


Solution

  • CGI applications are nothing but backend of HTTP kind protocol, so I guess you could naturally build REST API on top of it: http://en.wikipedia.org/wiki/Representational_state_transfer

    Also python have good build-in support for HTTP for better understanding from inside (in case u like to keep control on everything): https://docs.python.org/3/library/http.server.html#module-http.server

    Anyway, when your getting better in it your best bet to switch on a framework like these: https://www.djangoproject.com/ http://www.tornadoweb.org/en/stable/