freepost.cgi 669 B

123456789101112131415
  1. #!./venv/bin/python3
  2. import os
  3. from freepost import bottle
  4. # freepost uses Bottle's function get_url() extensively (see https://bottlepy.org/docs/dev/_modules/bottle.html#Bottle.get_url
  5. # for a description). This function uses the env variable SCRIPT_NAME internally,
  6. # which is set by Apache to "/freepost.cgi" when redirecting URLs from .htaccess.
  7. # The result is that all the URLs created by get_url() will start with "/freepost.cgi",
  8. # for example "/freepost.cgi/post/<post_id>" instead of "/post/<post_id>".
  9. # So, here it's overwritten to an empty string in order to remove the script name from the URLs.
  10. os.environ['SCRIPT_NAME'] = ''
  11. bottle.run(server='cgi')