Question: In Python: The script that delivers the image:http://hills.ccsf.edu/~dputnam/cs131a/monty_python.cgi The HTML page with that uses the images delivered bymonty_python.cgi: http://hills.ccsf.edu/~dputnam/exercise5.1.html This exercises requires that your create
In Python:
The script that delivers the image:http://hills.ccsf.edu/~dputnam/cs131a/monty_python.cgi
The HTML page with that uses the images delivered bymonty_python.cgi: http://hills.ccsf.edu/~dputnam/exercise5.1.html
This exercises requires that your create two files:
A Python CGI script named cs131a/monty_python.cgi.
An HTML page named public_html/ex5.1.html
5.2 TODO monty_python.cgi
1- The CGI script portion of the assignment is named monty_python.cgi. Your job in this exercise is to write a single line of code the line that opens the file to read as bytes.
2- Create a CGI script named monty_python.cgi. Use the code below.
3- Use the image file /users/dputnam/monty_python.jpgin your script. You can copy the image to your own account if you wish, but you dont have to.
4- When you complete the monty_python.cgi script, install it into your public_html/cs131a directory with the correct permissions.
You should be able to see your script running athttp://hills.ccsf.edu/~YourName/cs131a/monty_python.cgi
5- Create a standard HTML page named ex5.1.html that uses the image delivered by monty_python.cgi. The IMG tag will look like this:
Heres some code to get you started. You do have to write the one line of code that opens and reads the file as bytes.
#!/usr/local/bin/python3 -u # -u turns off output buffering so that the image # will not be sent until we turn buffering back on. # # Name: YOURNAME # File: monty_python.cgi # Desc: return a binary file to stdout (the web server) import sys image_path = '/users/dputnam/monty_python.jpg' # Read bytes rather than characters. ### YOU HAVE TO WRITE THIS LINE ### Open the file and read the entire thing into a variable named "data". >>>>>>>> YOUR CODE GOES HEREHeres an HTML page that will use your CGI script to deliver the image by using a link to the CGI script as the HREF in an IMG tag.
Copy ex5.3.html to your Hills public_html directory. Give it 0644 permissions.
CS 131A -- Exercise 5.3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
