I made a simple application that makes use of Python CGI scripts. I have a working local version (works fine with lighttpd), but now I'd like to upload it to Heroku. The application consists of 2 or 3 scripts that make operations on a file and print information back to the browser, so I don't think I'll need any module other than CGI.
But the Heroku documentation only explains how to upload Python applications with fancy web frameworks, and I'm not using any of those.
I want to know if it's possible to run CGI scripts on Heroku, and if so, how to do it.
Heroku Cedar is centered around self-hosting web applications, so you need to be able to bundle your application together and run it as a single command.
I think the easiest way would be to port your application to Flask. It isn't very complicated, especially if it is only 2 or 3 scripts.
Another option (depending on your performance requirements) would be to use the simple CGI server in the Python standard library and the Python buildpack. I think you would need to bundle up your scripts in a ./cgi-bin directory and start the server (in the procfile) with:
web: bin/python -m CGIHTTPServer $PORT
The most complex way would be to bundle lighttpd and your scripts together and write a shell script to start it all up. You would have to make sure your compiled binaries are compatible with Heroku. I would look at the PHP buildpack as a starting point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With