import getmetar from cgi import parse_qs def application(env, start_response): d = parse_qs(env['QUERY_STRING']) try: station = d.get('station', '')[0] except: station = "" #start_response('200 OK', [('Content-Type', 'text/plain')]) # return str.encode(station) metar = "" if station == "": metar = getmetar.extract_metar("UKBB") else: metar = getmetar.extract_metar(station.upper()) html = "" html += "" html += "" html += "" html += "" html += metar + "
" html += "" start_response('200 OK', [('Content-Type', 'text/html'), ('Content-Length', str(len(html)))]) return str.encode(html) def empty_func(a,b): return None if __name__ == "__main__": x = None y = empty_func print(application(x,y))