Esempio n. 1
0
def main(argv):
    """Read command line options and run app accordingly.

    Reads arguments from argv and applies relevant options.
    Args:
        argv (list): Output from sys.argv excluding first item.
    """

    from getopt import getopt, GetoptError

    # Get options and arguments from argv
    try:
        opts, args = getopt(argv, "d", ["debug"])
    except GetoptError:
        print("usage: run.py [-d] [--debug]")
        sys.exit()

    # Set options
    for opt, arg in opts:
        if opt == "-d":
            debug = True

    # Run the script
    try:
        app.run(debug=debug)
    except NameError:
        app.run()
Esempio n. 2
0
    def handle(self, app, host, port, use_debugger, use_reloader,
               threaded, processes, passthrough_errors, use_evalex,
               extra_files, profile, profile_restrictions, profile_dir, lint):
        # we don't need to run the server in request context
        # so just run it directly

        if profile:
            from werkzeug.contrib.profiler import ProfilerMiddleware
            app.wsgi_app = ProfilerMiddleware(app.wsgi_app,
                restrictions = profile_restrictions, profile_dir = profile_dir)

        if lint:
            from werkzeug.contrib.lint import LintMiddleware
            app.wsgi_app = LintMiddleware(app.wsgi_app)

        app.run(host = host,
                port = port,
                use_debugger = use_debugger,
                use_reloader = use_reloader,
                threaded = threaded,
                processes = processes,
                passthrough_errors = passthrough_errors,
                use_evalex = use_evalex,
                extra_files = extra_files,
                **self.server_options)
Esempio n. 3
0
def webserver(options, reload=False):
    from app import app
    print "Running server"
    if reload:
        # Con flask
        print "Trabajando con flask stand-alone"
        import gevent.wsgi
        from gevent import monkey
        import werkzeug.serving
        werkzeug.serving
        # http://flask.pocoo.org/snippets/34/ (2nd comment)
        monkey.patch_all()

        @werkzeug.serving.run_with_reloader
        def runServer():
            app.debug = True
            ws = gevent.wsgi.WSGIServer(('', options.port), app)
            ws.serve_forever()

        app.run()

    else:
        # Con Twisted
        from resources import site
        from twisted.internet import reactor

        from models import COMaster
        for x in COMaster.select():
            print x

        reactor.listenTCP(options.port, site) #@UndefinedVariable
        reactor.callLater(1, functools.partial(open_local_browser, port=options.port))    #@UndefinedVariable
        print "Iniciando servidor en http://0.0.0.0:%s" % options.port
        reactor.run() #@UndefinedVariable
Esempio n. 4
0
def run():
    """Runs development server.  Replaces run.py"""
    app.config.update(dict(
        DEBUG=True,
        TESTING=True,
        ))
    app.run()
Esempio n. 5
0
def go():
	import sys


	if "debug" in sys.argv:
		from gevent.pywsgi import WSGIServer
		print("Running in debug mode.")
		app.run(host='0.0.0.0')

	else:

		import cherrypy
		import logging


		def fixup_cherrypy_logs():
			loggers = logging.Logger.manager.loggerDict.keys()
			for name in loggers:
				if name.startswith('cherrypy.'):
					print("Fixing %s." % name)
					logging.getLogger(name).propagate = 0


		cherrypy.tree.graft(app, "/")
		cherrypy.server.unsubscribe()

		# Instantiate a new server object
		server = cherrypy._cpserver.Server()
		# Configure the server object
		if "all" in sys.argv:
			server.socket_host = "0.0.0.0"
		else:
			server.socket_host = "127.0.0.1"

		server.socket_port = 5000
		server.thread_pool = 8

		# For SSL Support
		# server.ssl_module            = 'pyopenssl'
		# server.ssl_certificate       = 'ssl/certificate.crt'
		# server.ssl_private_key       = 'ssl/private.key'
		# server.ssl_certificate_chain = 'ssl/bundle.crt'

		# Subscribe this server
		server.subscribe()

		# fixup_cherrypy_logs()

		if hasattr(cherrypy.engine, 'signal_handler'):
			cherrypy.engine.signal_handler.subscribe()
		# Start the server engine (Option 1 *and* 2)
		cherrypy.engine.start()
		cherrypy.engine.block()
		# fixup_cherrypy_logs()



	print()
	print("Interrupt!")
	print("Thread halted. App exiting.")
def web_devserver(host, port, debug):
    "Run the web app with the Flask development server"
    app.run(
        host=host,
        port=port,
        debug=debug,
    )
Esempio n. 7
0
def main():
    try:
        port = int(sys.argv[1])
    except:
        print 'Usage:\n\t./runserver port'
        sys.exit(1)
    app.run(host='0.0.0.0', debug=True, port=port)
Esempio n. 8
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--port', type=int, default=5000)

    args = parser.parse_args()

    app.run(host='0.0.0.0', port=args.port, threaded=True)
Esempio n. 9
0
def main(args):
    from app import app
    app.config['SQLALCHEMY_DATABASE_URI'] = args.db
    app.config['SQLALCHEMY_MIGRATE_REPO'] = args.migrate
    app.config['HOST'] = args.host
    app.config['PORT'] = args.port
    version = None
    try:
        with open('VERSION', 'r') as f:
            version = f.read().strip()
    except FileNotFoundError:
        pass
    if not version:
        try:
            version = subprocess.check_output(
                    ['git', 'describe', '--always', '--dirty=+']).decode('UTF-8')
        except:
            pass

    if version:
        app.config['VERSION'] = version
        app.logger.info('Running Deschedule version ' + version)
    else:
        app.logger.warn('Could not get version from file or command')

    app.config.from_object(args.config)

    if args.create:
        from app import db
        db.create_all()

    app.run(host=app.config['HOST'], port=app.config['PORT'], debug=args.debug)
def run():
    """
    Run the server.
    """

    # Set up the logger.
    if not os.path.isdir(os.path.join(script_dir, 'logs')):
        os.makedirs(os.path.join(script_dir, 'logs'))
    # Format the logs.
    formatter = logging.Formatter(
            "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    # Enable the logs to split files at midnight.
    handler = TimedRotatingFileHandler(
            os.path.join(script_dir, 'logs', 'TorSpider.log'),
            when='midnight', backupCount=7, interval=1)
    handler.setLevel(app.config['LOG_LEVEL'])
    handler.setFormatter(formatter)
    log = logging.getLogger('werkzeug')
    log.setLevel(app.config['LOG_LEVEL'])
    log.addHandler(handler)
    app.logger.addHandler(handler)
    app.logger.setLevel(app.config['APP_LOG_LEVEL'])

    # Set up the app server, port, and configuration.
    port = int(environ.get('PORT', app.config['LISTEN_PORT']))
    addr = environ.get('LISTEN_ADDR', app.config['LISTEN_ADDR'])
    if app.config['USETLS']:
        context = (app.config['CERT_FILE'], app.config['CERT_KEY_FILE'])
        app.run(host=addr, port=port, threaded=True, ssl_context=context)
    else:
        app.run(host=addr, port=port, threaded=True)
Esempio n. 11
0
def main():
    if len(sys.argv) > 1:
        port = int(sys.argv[2])
    else:
        port = 3000

    app.run(port = port, debug = True)
Esempio n. 12
0
def run_app():
    fqdn = getfqdn()
    Bootstrap(app)
    if 'scb' in fqdn:
        app.run(debug=True)
    else:
        app.run()
Esempio n. 13
0
def main():
  app.run(
          host='0.0.0.0',
          port=8080,
          #ssl_context=('etc/ssl/dev.sigmon.net.crt','etc/ssl/dev.sigmon.net.key'),
          debug=True,
          threaded=False,
          processes=5)
Esempio n. 14
0
def main():
    db.connect()
    setup_tables()
    register_blueprints()

    app.run(debug=config.DEBUG,
        host="0.0.0.0",
        port=int(os.environ.get("PORT", 5912)))
Esempio n. 15
0
 def run(self):
     self.logger.info("Listening on http://%s:%s/" % (self.host, self.port))
     #Enable read configuration generated by the GUI
     set_config_from_gui()
     try:
         app.run(server=self.server,quiet=True)
     except Exception, ex:
         self.logger.error(ex)
Esempio n. 16
0
def flask_http(debug=False, ssl=False):
    if (ssl):
        from OpenSSL import SSL
        context = SSL.Context(SSL.SSLv23_METHOD)
        context.use_privatekey_file('ssl/server.key')
        context.use_certificate_file('ssl/server.crt')
        app.run(host='0.0.0.0', port=8010, debug=debug, ssl_context=context)
    else:
        app.run(host='0.0.0.0', port=8010, debug=debug)
Esempio n. 17
0
def profile(length, profile_dir):
    """Start the application under the code profiler."""
    # 使用 python manage.py profile 启动程序后,终端会显示每条请求的分析数据,其中包含运行最慢的 25 个函数。
    # --length 选项可以修改报告中显示的函数数量
    # 如果指定了--profile-dir 选项,每条请求的分析数据就会保存到指定目录下的一个文件中
    from werkzeug.contrib.profiler import ProfilerMiddleware
    app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length],
                                      profile_dir=profile_dir)
    app.run()
Esempio n. 18
0
def _start(args):
    """
    Add args.path to sys.path
    import app
    app.run()
    """
    sys.path.insert(0, args.path)
    from app import app
    app.run(args.host, args.port)
Esempio n. 19
0
def run():
    app.host = sys.argv['-h'] if '-h' in sys.argv else '127.0.0.1'
    if '-t' in sys.argv:
        app.config['TESTING'] = True
        print 'Running in test mode.'
    app.debug = '-d' in sys.argv
    app.use_reloader = '-r' in sys.argv

    app.g = globals.load()
    app.run()
Esempio n. 20
0
def main():
    config = _get_config()

    if config['server'] == 'cherry':
        #Run the stable, cherrypy server
        from cherry import start
    	start()
    else:
        #Run the development server
        app.run(host=config['host'], port=config['port'], debug=config['DEBUG'])
Esempio n. 21
0
def main(argv=None):
  parser = get_argument_parser()
  args = parser.parse_args(argv)
  if args.external:
    HOST="0.0.0.0"
  else:
    HOST="localhost"
  PORT=args.port
  DEBUG=args.debug
  app.run(host=HOST, port=PORT, debug=DEBUG)
def main():
    # Set up logging
    logging.basicConfig(format='%(asctime)s - %(levelname)s %(funcName)s() - %(message)s',
                        filename=config.log_file_name,
                        level=config.log_level)
    logging.info('-- Starting the Software Assessment Framework --')

    app.config['WTF_CSRF_ENABLED'] = False
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    app.run(host=config.host, port=config.port, debug=True)
Esempio n. 23
0
def main(args):
    from app import app
    app.config['SQLALCHEMY_DATABASE_URI'] = args.db
    app.config['SQLALCHEMY_MIGRATE_REPO'] = args.migrate
    app.config.from_object(args.config)

    if args.create:
        from app import db
        db.create_all()

    app.run(host=args.host, port=args.port, debug=args.debug)
Esempio n. 24
0
def main():
    username = os.getenv("TEXR_USER")
    if username is None:
        username = os.getenv("USER")

    if username is None:
        print "Dont know who I am, can't start!"
        return

    app.me(username)
    app.run()
def run():
    print("""
    +===================================+
    ¦   Parkwood Vale Harriers Webapp   ¦
    +===================================+
    ¦   Stop the application by either  ¦
    ¦   closing the console window, or  ¦
    ¦         pressing CTRL+C.          ¦
    +===================================+
    ¦    Made by Christopher Stevens    ¦
	¦      GITHUB/PUBLIC VERSION        ¦
    +===================================+
    """)
    app.run(debug=True, use_reloader=False)
Esempio n. 26
0
  def run(debug, threaded, host, port):
    """
    This function handles command line parameters.
    Run the server using:

        python server.py

    Show the help text using:

        python server.py --help

    """

    HOST, PORT = host, port
    print "running on %s:%d" % (HOST, PORT)
    app.run(host=HOST, port=PORT, debug=True, threaded=threaded)
Esempio n. 27
0
def main():
    parser = optparse.OptionParser("usage: %prog [options]")
    parser.add_option(
        "-b", "--bind", dest="bind_addr", metavar="ADDR", help="IP addr or hostname to bind to (defaults to 0.0.0.0)"
    )
    parser.add_option(
        "-p", "--port", dest="port", type="int", metavar="PORT", help="port to bind to (defaults to 9090)"
    )

    (options, args) = parser.parse_args()

    app.config["BIND_ADDR"] = options.bind_addr or app.config.get("BIND_ADDR", "0.0.0.0")
    app.config["PORT"] = options.port or app.config.get("PORT", 9090)

    print("Docker Hadoop Dashboard, version %s" % VERSION)
    app.run(host=app.config["BIND_ADDR"], port=app.config["PORT"], debug=True)
Esempio n. 28
0
def flaskrun(app,
             default_host="127.0.0.1",
             default_port="5000"):
    """
    Takes a flask.Flask instance and runs it. Parses
    command-line flags to configure the app.
    """

    # Set up the command-line options
    parser = optparse.OptionParser()
    parser.add_option("-H", "--host",
                      help="Hostname of the Flask app " + \
                           "[default %s]" % default_host,
                      default=default_host)
    parser.add_option("-P", "--port",
                      help="Port for the Flask app " + \
                           "[default %s]" % default_port,
                      default=default_port)

    # Two options useful for debugging purposes, but
    # a bit dangerous so not exposed in the help message.
    parser.add_option("-d", "--debug",
                      action="store_true", dest="debug",
                      help=optparse.SUPPRESS_HELP)
    parser.add_option("-p", "--profile",
                      action="store_true", dest="profile",
                      help=optparse.SUPPRESS_HELP)

    options, _ = parser.parse_args()

    # If the user selects the profiling option, then we need
    # to do a little extra setup
    if options.profile:
        from werkzeug.contrib.profiler import ProfilerMiddleware

        app.config['PROFILE'] = True
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app,
                       restrictions=[30])
        options.debug = True

    app.run(
        debug=options.debug,
        host=options.host,
        port=int(options.port)
    )
Esempio n. 29
0
    def _spawn_live_server(self):
        self._process = None
        self.port = self.app.config.get('LIVESERVER_PORT', 8943)

        worker = lambda app, port: app.run(port=port, use_reloader=False, debug=True)

        self._process = multiprocessing.Process(
            target=worker, args=(self.app, self.port)
        )

        self._process.start()
        time.sleep(1)
Esempio n. 30
0
def main():
    # Set default configuration
    port = '8069'
    path = 'config/proxypos.yaml'
    # Start logg
    setup_logging()
    # Interactive mode
    logger = logging.getLogger(__name__)
    logger.info("ProxyPos server starting up...")

    if os.path.exists(path):
        with open(path, 'rt') as f:
            config = yaml.load(f.read())
        port = config['port']

    logger.info("Listening on http://%s:%s/" % ('localhost', port))
    server = WSGIRefServerAdapter(host='localhost',port=port)
    try:
        app.run(server=server,quiet=True)
    except Exception, ex:
        print ex
Esempio n. 31
0
from app import app
from arguments import args

if __name__ == '__main__':
    print(f'Arguments: {args}')
    options = dict(
        host='0.0.0.0',
        debug=args.debug,
        port=args.port,
        threaded=True
    )

    app.run(**options)
Esempio n. 32
0
def run():
	app.run(debug=True)
Esempio n. 33
0
from app import app, db
from models import User, Currency
from config import get_configuration

if __name__ == '__main__':
    # from events import create_event
    # from users import create_user
    #
    # create_user('ruslan', '123')
    #
    # ruslan = db.session.query(User).get(2)
    # admin = db.session.query(User).get(1)
    #
    # usd = db.session.query(Currency).filter(Currency.ticker=='USD').one()
    # eur = db.session.query(Currency).filter(Currency.ticker=='EUR').one()
    # cny = db.session.query(Currency).filter(Currency.ticker=='CNY').one()
    #
    # # create_event(ruslan, ruslan.get_account_by_currency(usd), admin.get_account_by_currency(usd), 10)
    # create_event(ruslan, ruslan.get_account_by_currency(usd), admin.get_account_by_currency(eur), 10)

    configuration = get_configuration()

    app.run(host=configuration.APP_HOST, port=configuration.APP_PORT)
Esempio n. 34
0
from app import app

#app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True
app.run(debug=True, port=8888)
Esempio n. 35
0
from app import app

if __name__ == "__main__":
    app.run(debug=True, port=3000)


Esempio n. 36
0
from app import app
import view

if __name__ == "__main__":
    app.run() # запускает метод run в экземпляре класса Flask
Esempio n. 37
0
"""
Flask Web App - Generated by www.AppSeed.us
AppSeed - developed by RoSoft | www.RoSoftware.ro
Licence: MIT
"""

import os
from app     import app #import flask app
from app     import db  #import db
from app     import admin
from app.cli import create_user  #import cli functions

#----------------------------------------
# launch
#----------------------------------------

# This Code will be executed if app is started using python:
# python ./app.py 
if __name__ == "__main__":
	
	# schema it's created based on classes defined in models.py 
	db.create_all()

	# create a test user using 
	# create_user( email, username, password)
	create_user( '*****@*****.**', 'appseed', 'pass')

	port = int(os.environ.get("PORT", 5000))
	app.run(host='127.0.0.1', port=port, debug=True)
	
from app import app
from app.routes import*

if __name__ == '__main__':
    app.run(debug=True)
Esempio n. 39
0
from app import app, db
from app.models import User, Post


@app.shell_context_processor
def make_shell_context():
    return {'db': db, 'User': User, 'Post': Post}


if __name__ == "__main__":
    app.run(host="0.0.0.0", port="4444")
Esempio n. 40
0
from app import app

if __name__ == '__main__':
    app.run("127.0.0.1", 8088)
Esempio n. 41
0
import os
from app import app

if __name__ == "__main__":
    app.secret_key = os.urandom(12)
    app.run(host="0.0.0.0", debug=True, port=4000)
Esempio n. 42
0
from app import app

app.run(debug=app.config['DEBUG'], port=4990)
Esempio n. 43
0
  
    
    

@app.route('/results')
def search_results(search):
    current_prices()
    res2 = dict(filter(lambda item: search.data['search'] in item[0], dictionary.items()))
    results = []
    search_string = search.data['search']

    if search.data['search'] == '':
        for key, value in res2.items():
            qry = db_session.query(Price)
            results = res2.all()

    if not results:
        flash('No results found!')
        return redirect('/')
    else:
        # display results
        return render_template('results.html', table=table)


if __name__ == '__main__':
    import os
    if 'WINGDB_ACTIVE' in os.environ:
        app.debug = False
    app.run(port=5001)
Esempio n. 44
0
# -*- coding: utf-8 -*-
from app import app
from app.config import Config

app.run(host=Config.host)


# from app import app, db
# from app.models import User
#
# @app.shell_context_processor
# def make_shell_context():
#     return {'db': db, 'User': User}
Esempio n. 45
0
import os
from app import app,SQLAlchemy,db

#app.config['SQLALCHEMY_DATABASE_URI'] = app.config['SQLALCHEMY_DATABASE_HEROKU']
#db = SQLAlchemy(app)

if __name__ == "__main__":
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)
    #app.run()
Esempio n. 46
0
from app import app

app.run(debug=True, port=3000, host="0.0.0.0")
Esempio n. 47
0
# Port variable to run the server on.
PORT = os.environ.get('PORT')


@app.errorhandler(404)
def not_found(error):
    """ error handler """
    LOG.error(error)
    return make_response(jsonify({'error': 'Not found'}), 404)


@app.route('/')
def index():
    """ static files serve """
    return send_from_directory('dist', 'index.html')


@app.route('/<path:path>')
def static_proxy(path):
    """ static folder serve """
    file_name = path.split('/')[-1]
    dir_name = os.path.join('dist', '/'.join(path.split('/')[:-1]))
    return send_from_directory(dir_name, file_name)


if __name__ == '__main__':
    LOG.info('running environment: %s', os.environ.get('ENV'))
    app.config['DEBUG'] = os.environ.get(
        'ENV') == 'development'  # Debug mode if development env
    app.run(host='0.0.0.0', port=int(PORT))  # Run the app
Esempio n. 48
0
# -*- coding: utf-8 -*-
from app import app

if __name__ == '__main__':
    app.run(debug=True, use_reloader=True)
Esempio n. 49
0
from app import app

PORT = 5000
DEBUG = True

if __name__ == '__main__':
    app.secret_key = "^A%DJAJU^JJ123"
    app.run(port=PORT, debug=DEBUG)
Esempio n. 50
0
import logging
import os
from app import app

# os.system("killall -9 gunicorn")
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
app = app

if __name__ == '__main__':
    ## production
    # current_dir_path = os.path.abspath(os.path.dirname(__file__))
    # os.system(f"cd {current_dir_path} && gunicorn -b 127.0.0.1:5000 --worker-class eventlet -w 1 run:app")

    ## development  --> 你应该在此模式下卸载eventlet包
    app.run(host='0.0.0.0')
    # 生产环s境可以注释
    # webbrowser.open("http://127.0.0.1:5000/login")
Esempio n. 51
0
###


@app.route('/<file_name>.txt')
def send_text_file(file_name):
    """Send your static text file."""
    file_dot_text = file_name + '.txt'
    return app.send_static_file(file_dot_text)


@app.after_request
def add_header(response):
    """
    Add headers to both force latest IE rendering engine or Chrome Frame,
    and also tell the browser not to cache the rendered page. If we wanted
    to we could change max-age to 600 seconds which would be 10 minutes.
    """
    response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
    response.headers['Cache-Control'] = 'public, max-age=0'
    return response


@app.errorhandler(404)
def page_not_found(error):
    """Custom 404 page."""
    return render_template('404.html'), 404


if __name__ == '__main__':
    app.run(debug=True, host="0.0.0.0", port="8080")
Esempio n. 52
0
        dec_c = chr((256 + ord(enc[i]) - ord(key_c)) % 256)
        dec.append(dec_c)
    return "".join(dec)


@app.route('/encrypt3')
@cross_origin(origin='localhost', headers=['Content- Type', 'Authorization'])
def encrypt3():
    baseString = request.args.get(
        'str')  # is no data sent this will return null

    final = personalEncryption(baseString)
    print('string received is ', baseString)
    return final


@app.route('/decrypt3')
@cross_origin(origin='localhost', headers=['Content- Type', 'Authorization'])
def decrypt3():
    baseString = request.args.get(
        'str')  # is no data sent this will return null

    final = personalDecryption(baseString)
    print('string received is ', baseString)
    return final


if __name__ == '__main__':
    # run!
    app.run()
Esempio n. 53
0
#! /usr/bin/env python
from app import app
app.run(debug=True, host="0.0.0.0", port=8090)
Esempio n. 54
0
#!flask/bin/python
import os
from app import app
port = int(os.environ.get("PORT", 33507))
app.run(host='0.0.0.0', port=port, debug=True)
Esempio n. 55
0
from app import app as application


if __name__ == '__main__':
    application.run()

Esempio n. 56
0
from app import app


if __name__ == "__main__":
    
    app.run(debug=True, host='0.0.0.0',port=5000)
Esempio n. 57
0
File: run.py Progetto: cash2one/apc
# -*- coding: utf-8 -*-

from app import app


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)
Esempio n. 58
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'BuGoNee'
'''
Some Explaination should be in here.
'''

from app import app
app.run(debug=True, host='0.0.0.0')
if __name__ == '__main__':
    pass
Esempio n. 59
0
from app import app

app.run(debug=True, port=80)
Esempio n. 60
0
from app import app, views

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000, debug=True)