Displaying charts saved on EC2 server in web browser

Assuming we have apache server running, and chart that we want to display is /var/www/images/foo_chart.png,
we place display_chart.py python script in /var/www/cgi-bin.
The script is:

#!/usr/bin/python
if __name__ == "__main__":
    print "Content-type: image/png\n"
    print file(r"/var/www/images/foo_chart.png", "r").read()

Now, in web browser we type

http://ec2-107-20-179-198.compute-1.amazonaws.com/cgi-bin/display_chart.py

and the page with our chart should be pulled up.
Instructions to install and start apache server can be found here.
Note: to get apache server working you need to allow port 80 for HTTP. This is easily done through amazon web-services personal account page -> dashboard -> security groups.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s