Auto-detect the location of www/
Either ../www or /usr/share/morss Adapted README accordinglymaster
parent
39b0a1d7cc
commit
59139272fd
15
README.md
15
README.md
|
@ -144,17 +144,12 @@ Running this command should do:
|
|||
uwsgi --http :9090 --plugin python --wsgi-file main.py
|
||||
```
|
||||
|
||||
However, one problem might be how to serve the provided `index.html` file if it
|
||||
isn't in the same directory. Therefore you can add this at the end of the
|
||||
command to point to another directory `--pyargv '--root ../../www/'`.
|
||||
|
||||
|
||||
#### Using morss' internal HTTP server
|
||||
|
||||
Morss can run its own HTTP server. The later should start when you run morss
|
||||
without any argument, on port 8080.
|
||||
|
||||
You can change the port and the location of the `www/` folder like this `python -m morss 9000 --root ../../www`.
|
||||
You can change the port like this `python -m morss 9000`.
|
||||
|
||||
#### Passing arguments
|
||||
|
||||
|
@ -174,9 +169,9 @@ Works like a charm with [Tiny Tiny RSS](http://tt-rss.org/redmine/projects/tt-rs
|
|||
|
||||
Run:
|
||||
```
|
||||
python[2.7] -m morss [argwithoutvalue] [argwithvalue=value] [...] FEEDURL
|
||||
morss [argwithoutvalue] [argwithvalue=value] [...] FEEDURL
|
||||
```
|
||||
For example: `python -m morss debug http://feeds.bbci.co.uk/news/rss.xml`
|
||||
For example: `morss debug http://feeds.bbci.co.uk/news/rss.xml`
|
||||
|
||||
*(Brackets indicate optional text)*
|
||||
|
||||
|
@ -189,9 +184,9 @@ scripts can be run on top of the RSS feed, using its
|
|||
|
||||
To use this script, you have to enable "(Unix) command" in liferea feed settings, and use the command:
|
||||
```
|
||||
[python[2.7]] PATH/TO/MORSS/main.py [argwithoutvalue] [argwithvalue=value] [...] FEEDURL
|
||||
morss [argwithoutvalue] [argwithvalue=value] [...] FEEDURL
|
||||
```
|
||||
For example: `python2.7 PATH/TO/MORSS/main.py http://feeds.bbci.co.uk/news/rss.xml`
|
||||
For example: `morss http://feeds.bbci.co.uk/news/rss.xml`
|
||||
|
||||
*(Brackets indicate optional text)*
|
||||
|
||||
|
|
|
@ -620,21 +620,24 @@ def cgi_file_handler(environ, start_response, app):
|
|||
if url == '':
|
||||
url = 'index.html'
|
||||
|
||||
if '--root' in sys.argv[1:]:
|
||||
path = os.path.join(sys.argv[-1], url)
|
||||
paths = [os.path.join(sys.prefix, 'share/morss', url),
|
||||
os.path.join(os.path.dirname(__file__), '../www', url)]
|
||||
|
||||
for path in paths:
|
||||
try:
|
||||
print(path)
|
||||
body = open(path, 'rb').read()
|
||||
|
||||
headers['status'] = '200 OK'
|
||||
headers['content-type'] = files[url]
|
||||
start_response(headers['status'], list(headers.items()))
|
||||
return [body]
|
||||
|
||||
except IOError:
|
||||
continue
|
||||
|
||||
else:
|
||||
path = url
|
||||
|
||||
try:
|
||||
body = open(path, 'rb').read()
|
||||
|
||||
headers['status'] = '200 OK'
|
||||
headers['content-type'] = files[url]
|
||||
start_response(headers['status'], list(headers.items()))
|
||||
return [body]
|
||||
|
||||
except IOError:
|
||||
# the for loop did not return, so here we are, i.e. no file found
|
||||
headers['status'] = '404 Not found'
|
||||
start_response(headers['status'], list(headers.items()))
|
||||
return ['Error %s' % headers['status']]
|
||||
|
@ -762,7 +765,7 @@ def main():
|
|||
|
||||
wsgiref.handlers.CGIHandler().run(app)
|
||||
|
||||
elif len(sys.argv) <= 1 or isInt(sys.argv[1]) or '--root' in sys.argv[1:]:
|
||||
elif len(sys.argv) <= 1 or isInt(sys.argv[1]):
|
||||
# start internal (basic) http server
|
||||
|
||||
if len(sys.argv) > 1 and isInt(sys.argv[1]):
|
||||
|
|
Loading…
Reference in New Issue