| #!/usr/bin/env python |
| # Copyright 2017 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| """Runs a local development server.""" |
| |
| import getpass |
| import os |
| import subprocess |
| |
| import fire |
| from werkzeug import security |
| |
| |
| def LocalServer(port=8080): |
| """Starts a local development server with autoreload.""" |
| cmd = tuple( |
| 'gunicorn -b=:{port} main:app --workers=1' |
| ' --reload'.format(port=int(port)).split()) |
| password = getpass.getpass() |
| hashed = security.generate_password_hash(password) |
| env = dict( |
| os.environ, |
| ADMIN_PASSWORD_HASH=hashed, |
| CIDB_CRED_DIR='creds/cidb.dbg', |
| DEBUG='True', |
| IS_SERVICE='False') |
| subprocess.call(cmd, env=env) |
| |
| |
| if __name__ == '__main__': |
| fire.Fire(LocalServer) |