Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Forked from aliles/flask_quickstart.py
Created March 13, 2016 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxfight3r/2a1404ecb73fb97bca6f to your computer and use it in GitHub Desktop.
Save tuxfight3r/2a1404ecb73fb97bca6f to your computer and use it in GitHub Desktop.
Example CLI help output for possible re-implementation of boolean flags for begins.
from flask import Flask
import begin
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@begin.start(env_prefix='WEB_')
@begin.convert(port=int, debug=begin.utils.tobool)
def main(host='127.0.0.1', port=8080, debug=False):
app.run(host=host, port=port, debug=debug)
$ WEB_DEBUG=false python flask_quickstart.py --help
usage: flask_quickstart.py [--help] [--host WEB_HOST] [--port WEB_PORT]
[--debug] [--no-debug]
optional arguments:
--help show this help message and exit
--host WEB_HOST, -h WEB_HOST
(default: 127.0.0.1)
--port WEB_PORT, -p WEB_PORT
(default: 8080)
--debug (default: False)
--no-debug
$ WEB_DEBUG=true python flask_quickstart.py --help
usage: flask_quickstart.py [--help] [--host WEB_HOST] [--port WEB_PORT]
[--debug] [--no-debug]
optional arguments:
--help show this help message and exit
--host WEB_HOST, -h WEB_HOST
(default: 127.0.0.1)
--port WEB_PORT, -p WEB_PORT
(default: 8080)
--debug
--no-debug (default: True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment