[changing into CGI script Panu Kalliokoski **20130819142753 Ignore-this: d2e07a55a77c76109a57018c7b37a5af ] move ./extract.py ./mexse.cgi hunk ./mexse.cgi 4 -import extractor, ctypes, os.path, hashlib, urllib +import cgi, os.path, hashlib, urllib +import extractor, ctypes + +## Automatic metadata analyses hunk ./mexse.cgi 48 - metadata.append(('HTTP', 'address', url)) + metadata.append(('HTTP', 'location', url)) hunk ./mexse.cgi 51 +## HTTP and HTML stuff + +script_name = 'mexse.cgi' + +def print_header(): print 'content-type: text/html; charset=utf-8\n' + +def redirect(qs): + print 'Status: 302 moved\nLocation: %s%s\n' % (script_name, qs) + +def start_html(title): + print '''''' + print '%s' % title + print '' + print '\n

%s

' % title + +def end_html(): + print '' + +## Request handlers + +def kysy_tiedostoa(tnimi, form): + print_header() + start_html('Mexse — Metadata Extraction Service') + print ''' +

This service helps you to produce well-formed metadata for + your data. The service provides means to:

+ +

However, the service does not store the file itself or the + metadata. It is up to you to download and store the + metadata.

''' + end_html() + + +## Script logic + +def handle_request(form): + handlers = { + 'kysy_tiedostoa': kysy_tiedostoa, + } + for param in handlers: + if param in form: + handlers[param](form.getfirst(param), form) + break + else: kysy_tiedostoa('', form) +