https://github.com/NVIDIA/DIGITS
Raw File
Tip revision: b4f326186f5f02b6fd08e19a771735298808e7b3 authored by Luke Yeager on 22 April 2015, 20:33:40 UTC
Change default resize mode to squash
Tip revision: b4f3261
digits-devserver
#!/usr/bin/env python
# Copyright (c) 2014-2015, NVIDIA CORPORATION.  All rights reserved.

import sys
import argparse

# Only required if using SocketIO.run() and app.debug = False
from gevent import monkey; monkey.patch_all()

if __name__ == '__main__':
    print '  ___ ___ ___ ___ _____ ___'
    print ' |   \_ _/ __|_ _|_   _/ __|'
    print ' | |) | | (_ || |  | | \__ \\'
    print ' |___/___\___|___| |_| |___/'
    print

    parser = argparse.ArgumentParser(description='Run DIGITS in debug mode')
    parser.add_argument('-p', '--port',
            type=int,
            default=5000,
            help='Port to run app on (default 5000)'
            )
    parser.add_argument('-c', '--config',
            action='store_true',
            help='Reconfigure the application'
            )
    parser.add_argument('-d', '--debug',
            action='store_true',
            help='Run the application in debug mode (with the reloader)'
            )

    args = vars(parser.parse_args())

    from digits import config

    if not config.valid_config() or args['config']:
        if not config.prompt_config():
            sys.exit(1)

    from digits.webapp import app, socketio, scheduler

    try:
        if not scheduler.start():
            print 'ERROR: Scheduler would not start'
        else:
            app.debug = args['debug']
            socketio.run(app, '0.0.0.0', args['port'],
                    policy_server=False
                    )
    except KeyboardInterrupt:
        pass
    finally:
        scheduler.stop()

back to top