I'm trying to pass arguments in a Flask application with argparse:
app = Flask(__name__)
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--environ", dest='environ', default='production',
help="Server environment")
args = parser.parse_args()
if args.environ == 'dev':
app.config.from_pyfile("dev.cfg", silent=True)
else:
app.config.from_pyfile("product.cfg", silent=True)
Everything is OK when I run the script directly.
However I don't know how to pass "-e dev" argument in uwsgi config file, pyargv
cannot handle this kind of argument.