Skip to content

The stack from HTML to Apache to Python

nilnullzip edited this page Jul 1, 2011 · 2 revisions

The src/StalkerBot.py sever is pretty good but it's only single threaded. And it's not what we use on the AWS server.

So under AWS we run the real thing, Apache, which serves up HTML pages and runs CGI scrips. With Apache, we use cgi/StakerBotCGI.py, which is a standalone application that follows the CGI interface conventions. Here's how it works:

  1. User browses http://StalkerBot.com/index.html. That's our front page written by Melissa.

  2. When the viewer enters a HN ID (dstein64) on our web page, the javascript code in our front page HTML makes a GET request for:

    http:/cgi-bin/StalkerBotCGI.py?userid=dstein64

  3. That GET instructs Apache to fork a process to run StalkerBotCGI.py standalone. Thus each view of our front page forks a separate instance of StalkerBotCGI.py. Apache captures the stdout from that process and returns it to Javascript, which uses it to render the emotion icons.

Thus we have Ajax! It works pretty well.

Actually there are other optimizations to be had to improve performance. In particular, the CGI integration with Apache can be made more efficient using mod_python. That's another optimization project.

Clone this wiki locally