diff --git a/README.md b/README.md index ab11f2f..3b893e4 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ GNU AGPLv3 code Further options: - Change what morss does -- `debug`: to have some feedback from the script execution. Useful for debugging. NB. for cli use, set the environment variable `DEBUG=1` +- Environment variable `DEBUG=`: to have some feedback from the script execution. Useful for debugging. On Apache, can be set via the `SetEnv` instruction - `silent`: don't output the final RSS (useless on its own, but can be nice when debugging) - `callback=NAME`: for JSONP calls - `cors`: allow Cross-origin resource sharing (allows XHR calls from other servers) diff --git a/morss/cgi.py b/morss/cgi.py index 68c891a..47d727d 100644 --- a/morss/cgi.py +++ b/morss/cgi.py @@ -39,8 +39,11 @@ def cgi_parse_environ(environ): # get options if 'REQUEST_URI' in environ: + # when running on Apache url = environ['REQUEST_URI'][1:] + else: + # when using internal server url = environ['PATH_INFO'][1:] if environ['QUERY_STRING']: diff --git a/morss/morss.py b/morss/morss.py index ac207d9..e6ffd74 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -39,14 +39,13 @@ class MorssException(Exception): def log(txt): - if ('DEBUG' in os.environ - or ':debug' in os.environ.get('REQUEST_URI', '') - or ':debug' in os.environ.get('PATH_INFO', '') - ): + if 'DEBUG' in os.environ: if 'REQUEST_URI' in os.environ: + # when running on Apache open('morss.log', 'a').write("%s\n" % repr(txt)) else: + # when using internal server or cli print(repr(txt))