Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to parameters #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion resweb/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from functools import wraps
from flask import Flask, g, redirect, request, Response, render_template, url_for
from pyres import ResQ, failure
import argparse


from resweb.views import (
Overview,
Expand Down Expand Up @@ -284,6 +286,18 @@ def delayed_timestamp(timestamp):
return render_template('delayed_timestamp.html', data=data)

def main():
app.run(host=app.config['SERVER_HOST'], port=int(app.config['SERVER_PORT']), debug=True)
parser = argparse.ArgumentParser(description='Optional app description')
parser.add_argument('--redishost', type=str, help='Set redis host:port')
parser.add_argument('--redispass', type=str, help='Set redis password')
parser.add_argument('--host', type=str, help='Set server host')
parser.add_argument('--port', type=int, help='Set server port')
args = parser.parse_args()
app.config['SERVER_PORT'] = args.port or int(app.config.get('SERVER_PORT', 5001))
app.config['SERVER_HOST'] = args.host or app.config.get('SERVER_HOST', "127.0.0.1")
app.config['RESWEB_HOST'] = args.redishost or app.config.get('RESWEB_HOST', "127.0.0.1:6379")
app.config['RESWEB_PASSWORD'] = args.redispass or app.config.get('RESWEB_PASSWORD', None)

# Required positional argument
app.run(host=app.config['SERVER_HOST'], port=app.config['SERVER_PORT'], debug=True)
if __name__ == '__main__':
main()