User:Eleanorg/1.2/Forbidden Pixels/Receiving URL where data is hosted
The site will need to ask participants for the URL of the pixel data they're hosting.This is my first time doing form processing in python: the html form asks for the url; it passes it to a simple script. Next step is for that script to add it to the list of URLs, and to check whether there is a string there matching the regex.
URL input form
<!DOCTYPE html>
<html>
<head>
<title>A form talking to a python script</title>
<style type="text/css">
</style>
</head>
<body>
<form action="form.cgi" name="inputForm"> <!--pushes form input to form.py script -->
Paste url:
<input name="url">
<input type="submit">
</form>
</body>
</html>
Python script grabbing URL submitted
Saved as .cgi within cgi-bin on server.
#!/usr/bin/python
import cgi
import cgitb; cgitb.enable() #what do these do?
htmlHeader = """<!DOCTYPE html>
<html>
<head>
<title>A form talking to a python script</title>
<style type="text/css">
</style>
</head>
<body>"""
print "Content-Type: text/html" //important - won't print in browser without these 2 lines
print
print htmlHeader
form = cgi.FieldStorage() //Grabs whatever input comes from form
url = form['url'].value // assigns form's url field input to var 'url'
print url
print """
</body>
</html>"""