config_handler.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. with open('config.json', 'r', encoding='utf8', errors='ignore') as f:
  34. data = json.loads(f.read())
  35. LISTEN_PORT = data['LISTEN_PORT']
  36. DATE = data['DATE']
  37. DATE_TOLERANCE = data['DATE_TOLERANCE']
  38. GEOCITIES_FIX = data['GEOCITIES_FIX']
  39. QUICK_IMAGES = data['QUICK_IMAGES']
  40. WAYBACK_API = data['WAYBACK_API']
  41. CONTENT_TYPE_ENCODING = data['CONTENT_TYPE_ENCODING']
  42. SILENT = data['SILENT']
  43. SETTINGS_PAGE = data['SETTINGS_PAGE']