plutopluto

git clone https://git.ce9e.org/plutopluto.git

commit
a4360714725ed064a866d95dddbf6f20ce775f33
parent
350cd51302eb056b3cbb4d6454bbaaed1df51309
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2014-09-25 17:37
allow to configure using config file

Diffstat

M server.py 15 ++++++++++++---

1 files changed, 12 insertions, 3 deletions


diff --git a/server.py b/server.py

@@ -1,5 +1,6 @@
    1     1 #!/usr/bin/env python
    2     2 
   -1     3 import sys
    3     4 from time import mktime, time
    4     5 import argparse
    5     6 
@@ -87,9 +88,17 @@ def  config():
   87    88 if __name__ == '__main__':
   88    89 	parser = argparse.ArgumentParser()
   89    90 	parser.add_argument('-d', '--debug', action='store_true')
   90    -1 	parser.add_argument('urls', metavar='url', nargs='+')
   -1    91 	parser.add_argument('-c', '--config')
   -1    92 	parser.add_argument('urls', metavar='url', nargs='*')
   91    93 	args = parser.parse_args()
   92    94 
   -1    95 	if args.config:
   -1    96 		app.config.from_pyfile(args.config)
   93    97 	app.debug = args.debug
   94    -1 	app.config['URLS'] = args.urls
   95    -1 	app.run()
   -1    98 	app.config['URLS'] = args.urls + app.config.get('URLS', [])
   -1    99 
   -1   100 	if not app.config['URLS']:
   -1   101 		print("Error: No urls provided")
   -1   102 		sys.exit(1)
   -1   103 
   -1   104 	app.run(app.config.get('HOST'), app.config.get('PORT'))