Python CGI setup (for Hostgator hosting)

In this post we will enable Python CGI for Hostgator

Create a .htaccess file and put following contents in this file:

This will make the web server to interprete .py file as Python CGI script.


Next create a python file (named here) with following code:

And set this file’s permission setting so that Owner, Group and Public have “execute” permission for this file (Or set 755 permission simply)

Visit http://server_address/app_path/, you will see a page with “hello” printed.



The first two lines of code is necessary, otherwise you will get a “500 Internal Server Error”.


  • El Blog del Geek

    Tiene un tiempo de espera para que se reflejen los cambios o al hacer las modificaciones es el cambio inmediato.

    • Ray Silver

      Lo he testado con 1on1/ionos y estos servicios no ofrecen soporte para python, después lo intenté con Hostgator y funcionó inmediatamente

  • Pete

    Excellent. As of June 2020 these instructions still work.