Some experiments with web applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
983 B

  1. #!/usr/bin/python
  2. # -*- coding: iso-8859-1 -*-
  3. import cgi
  4. import urllib
  5. import urllib2
  6. # get cgi object
  7. form = cgi.FieldStorage()
  8. url = "http://widgets.vvo-online.de/abfahrtsmonitor/"
  9. querytype = ""
  10. ort = ""
  11. hst = ""
  12. vz = ""
  13. vm = ""
  14. timestamp = ""
  15. # check for queries
  16. if (form.getvalue('query')):
  17. query = form.getvalue('query')
  18. if (form.getvalue('ort')):
  19. ort = form.getvalue('ort')
  20. if (form.getvalue('hst')):
  21. hst = form.getvalue('hst')
  22. if (form.getvalue('vz')):
  23. vz = form.getvalue('vz')
  24. if (form.getvalue('vm')):
  25. vm = form.getvalue('vm')
  26. if (form.getvalue('timestamp')):
  27. timestamp = form.getvalue('timestamp')
  28. validqueries = ["haltestelle.do", "abfahrten.do"]
  29. queries = {
  30. "ort": ort,
  31. "hst": hst,
  32. "vz": vz,
  33. "vm": vm,
  34. "timestamp": timestamp
  35. }
  36. if (query in validqueries):
  37. url += query + "?" + urllib.urlencode(queries)
  38. data = urllib2.urlopen(url).read()
  39. else:
  40. data = "[]"
  41. print("Content-type: text/html\n\n")
  42. print(data)