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.

44 lines
901 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. if (form.getvalue(key)):
  24. queries[key] = form.getvalue(key)
  25. # call the vvo server if the query is valid
  26. if (query in validqueries):
  27. url += query + "?" + urllib.urlencode(queries)
  28. data = urllib2.urlopen(url).read()
  29. else:
  30. data = "[]"
  31. # return the http response with the data received from server
  32. # or an empty array if query was invalid
  33. print("Content-type: text/html\n\n")
  34. print(data)