I would like to pass command-line parameters to a wsgi script. Here's an example:

app.py
-------------------------------
import argparse

from flask import Flask

parser = argparse.ArgumentParser()

parser.add_argument(
    "--important_parameter",
    required=False,
    type=str,
    default='127.0.0.1')

args = parser.parse_args()

important_parameter = args.important_parameter

app = Flask(__name__)

@app.route('/')
def index():
    return "index"

if __name__ == '__main__':
    app.run()
-------------------------------

I can pass parameters to it by running

        $ python app.py --important_parameter 15

I can call this script using uwsgi with the following:

        $ uwsgi --http 127.0.0.1:5000 --wsgi-file app.py --callable app

Or with the following wsgi-file:

app.ini
-------------------------------
[uwsgi]
http = 127.0.0.1:5000
wsgi-file = app.py
callable = app
-------------------------------

Does uwsgi allow passing in that important_parameter somehow? I've searched online and found very terse solutions I didn't understand and couldn't make work. I've also considered passing the information through environment variables, but I would much prefer this method.

Thank you very much for any help.

Cheers,
Thomas
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to