#!/usr/bin/python3 import time start_time = time.time() import locale # Ensures that subsequent open()s locale.getpreferredencoding = lambda: 'UTF-8' # are UTF-8 encoded. import cgi import cgitb cgitb.enable() from find import * print("Content-Type: text/html") # HTML is following print() # blank line, end of headers # counter try: content_file = open('computatio', 'r') count = int(content_file.read()) except: open('computatio', 'w').write("0") open('computatio', 'r').close() count=0 with open('computatio', 'w') as content_file: count += 1 content_file.write(str(count)) with open('template', 'r') as content_file: template = content_file.read() form = cgi.FieldStorage() search = form.getfirst("key") if search == None or len(search) > 20: search = "a" if search.isdigit(): # [[1, ['A', 'ABATE', 'ABDICATE']]] search = search.zfill(4) answers = [[search, ['', '', '']]] else: answers = spit_answers(search) links="" output="" if answers == []: search = '' answers = [['1', ['', '', '']]] if len(answers) > 1: answers = [answers[0]] # if len(answers) == 1: pagina = str(answers[0][0]).zfill(4) arquivo = pagina + ".jpg" palavras = answers[0][1] words = "page " + str(answers[0][0]) + ": " for eachword in palavras: words = words + eachword + " - " #print(pagina) #output = output + "
\n" #output = output + "" + "[" + pagina + "] " + link_after + "
" elif pagina == "0964": link_before = link.replace('$pagina$', page_before) links = "" + link_before + " [" + pagina + "]" + "
" else: link_before = link.replace('$pagina$', page_before) link_after = link.replace('$pagina$', page_after) links = "" + link_before + " [" + pagina + "] " + link_after + "
" #links = "" + words + "\n" # output = '