config_handler.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import json
  2. # Listen port for the HTTP proxy.
  3. global LISTEN_PORT
  4. # Date to get pages from Wayback. YYYYMMDD, YYYYMM and YYYY formats are
  5. # accepted, the more specific the better.
  6. global DATE
  7. # Allow the client to load pages and assets up to X days after DATE.
  8. # Set to None to disable this restriction.
  9. global DATE_TOLERANCE
  10. # Send Geocities requests to oocities.org if set to True.
  11. global GEOCITIES_FIX
  12. # Use the original Wayback Machine URL as a shortcut when loading images.
  13. # May result in faster page loads, but all images will point to
  14. # http://web.archive.org/... as a side effect. Set this value to 2 to enable an
  15. # experimental mode using authentication on top of the original URLs instead
  16. # (which is not supported by Internet Explorer and some other browsers).
  17. global QUICK_IMAGES
  18. # Use the Wayback Machine Availability API to find the closest available
  19. # snapshot to the desired date, instead of directly requesting that date. Helps
  20. # in situations where an image returns a server error on the desired date, but
  21. # is available at an earlier date. As a side effect, pages will take longer to
  22. # load due to the added API call. If enabled, this option will disable the
  23. # QUICK_IMAGES bypass mechanism built into the PAC file.
  24. global WAYBACK_API
  25. # Allow the Content-Type header to contain an encoding. Some old browsers
  26. # (Mosaic?) don't understand that and fail to load anything - set this to
  27. # False if you're using one of them.
  28. global CONTENT_TYPE_ENCODING
  29. # Disables logging if set to True.
  30. global SILENT
  31. # Enables the settings page on http://web.archive.org if set to True.
  32. global SETTINGS_PAGE
  33. try:
  34. with open("config.json") as f:
  35. data = json.loads(f.read())
  36. LISTEN_PORT = data["LISTEN_PORT"]
  37. DATE = data["DATE"]
  38. DATE_TOLERANCE = data["DATE_TOLERANCE"]
  39. GEOCITIES_FIX = data["GEOCITIES_FIX"]
  40. QUICK_IMAGES = data["QUICK_IMAGES"]
  41. WAYBACK_API = data["WAYBACK_API"]
  42. CONTENT_TYPE_ENCODING = data["CONTENT_TYPE_ENCODING"]
  43. SILENT = data["SILENT"]
  44. SETTINGS_PAGE = data["SETTINGS_PAGE"]
  45. except EnvironmentError as e:
  46. print("Wops! Error opening config.json")