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.

45 lines
915 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. query = ""
  10. queries = {
  11. "ort": "",
  12. "hst": "",
  13. "vz": "",
  14. "vm": "",
  15. "timestamp": ""
  16. }
  17. # available server scripts = valid queries
  18. validqueries = ["haltestelle.do", "abfahrten.do"]
  19. # check for queries
  20. if (form.getvalue('query')):
  21. query = form.getvalue('query')
  22. for key in queries:
  23. #.viewkeys():
  24. if (form.getvalue(key)):
  25. queries[key] = form.getvalue(key)
  26. # call the vvo server if the query is valid
  27. if (query in validqueries):
  28. url += query + "?" + urllib.urlencode(queries)
  29. data = urllib2.urlopen(url).read()
  30. else:
  31. data = "[]"
  32. # return the http response with the data received from server
  33. # or an empty array if query was invalid
  34. print("Content-type: text/html\n\n")
  35. print(data)