Exemple #1
0
def main():
    logging.info("... done.")

    if "PROFILE" in configuration['flask_options'] and configuration['flask_options']["PROFILE"]:
        print "Profiling!"
        from werkzeug.contrib.profiler import ProfilerMiddleware
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions = [30], sort_by=('cumulative','time','calls'))
        del configuration['flask_options']["PROFILE"]

    app.run(**configuration['flask_options'])
Exemple #2
0
def main():
    logging.info("... done.")

    if "PROFILE" in configuration['flask_options'] and configuration['flask_options']["PROFILE"]:
        print "Profiling!"
        from werkzeug.contrib.profiler import ProfilerMiddleware
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions = [30], sort_by=('cumulative','time','calls'))
        del configuration['flask_options']["PROFILE"]

    app.run(**configuration['flask_options'])
Exemple #3
0
def main():
    logging.info("main: ...done.")
    flask_options = Configuration().get_flask();

    if "profiler" in flask_options and flask_options["profiler"]:
        print "Profiling!"
        from werkzeug.contrib.profiler import ProfilerMiddleware
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions = [30], sort_by=('cumulative','time','calls'))
        del flask_options["profiler"]

    app.run(**flask_options)
Exemple #4
0
def main():
    set_logfocus(logfocus)
    logging.info("... done.")

    # just for debugging
    # if options["debug"]:
    #  logging.info(str(app.url_map))

    global configuration
    if not configuration:
        configuration = get_configuration()
    app.run(**configuration['flask_options'])
Exemple #5
0
def main():
    set_logfocus(logfocus)
    logging.info("... done.")

    # just for debugging
    # if options["debug"]:
    #  logging.info(str(app.url_map))

    global configuration
    if not configuration:
        configuration = get_configuration()
    app.run(**configuration['flask_options'])
Exemple #6
0
def main():
    logging.info("main: ...done.")
    flask_options = Configuration().get_flask()

    if "profiler" in flask_options and flask_options["profiler"]:
        print "Profiling!"
        from werkzeug.contrib.profiler import ProfilerMiddleware
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app,
                                          restrictions=[30],
                                          sort_by=('cumulative', 'time',
                                                   'calls'))
        del flask_options["profiler"]

    app.run(**flask_options)
Exemple #7
0
 def start():
     if len(sys.argv) > 1:
         if sys.argv[1] == ("dev"):
             app.config.from_object('base.config.DevelopmentConfig')
         elif sys.argv[1] == "test":
             app.config.from_object('base.config.TestingConfig')
             # Delete db if it exists
             if os.path.isfile(app.config["DBFILE"]):
                 os.remove(app.config["DBFILE"])
             MainApplication.findTests()
     if len(sys.argv) == 1 or sys.argv[1] == "prod" or None:
         app.config.from_object('base.config.ProductionConfig')
     MainApplication.initJob1()
     logging.basicConfig(filename=app.config["LOGFILE"],
                         level=logging.DEBUG)
     app.run(app.config["HOST"], app.config["PORT"])
Exemple #8
0
 def start():
     if len(sys.argv) > 1:
         if sys.argv[1] == ("dev"):
             app.config.from_object('base.config.DevelopmentConfig')
         elif sys.argv[1] == "test":
             app.config.from_object('base.config.TestingConfig')
             # Delete db if it exists
             if os.path.isfile(app.config["DBFILE"]):
                 os.remove(app.config["DBFILE"])
             MainApplication.findTests()
     if len(sys.argv) == 1 or sys.argv[1] == "prod" or None:
         app.config.from_object('base.config.ProductionConfig')
     MainApplication.initJob1()
     logging.basicConfig(filename=app.config["LOGFILE"],level=logging.DEBUG)
     app.run(
         app.config["HOST"],
         app.config["PORT"]
     )
Exemple #9
0
def main():
    set_logfocus(logfocus)
    logging.info("... done.")

    # just for debugging
    # if options["debug"]:
    #  logging.info(str(app.url_map))

    global configuration
    if not configuration:
        configuration = get_configuration()
    if "PROFILE" in configuration['flask_options'] and configuration['flask_options']["PROFILE"]:
        print "Profiling!"
        from werkzeug.contrib.profiler import ProfilerMiddleware
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions = [30], sort_by=('cumulative','time','calls'))
        del configuration['flask_options']["PROFILE"]

    app.run(**configuration['flask_options'])
Exemple #10
0
def main():
    set_logfocus(logfocus)
    logging.info("... done.")

    # just for debugging
    # if options["debug"]:
    #  logging.info(str(app.url_map))

    global configuration
    if not configuration:
        configuration = get_configuration()
    if "PROFILE" in configuration['flask_options'] and configuration[
            'flask_options']["PROFILE"]:
        print "Profiling!"
        from werkzeug.contrib.profiler import ProfilerMiddleware
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app,
                                          restrictions=[30],
                                          sort_by=('cumulative', 'time',
                                                   'calls'))
        del configuration['flask_options']["PROFILE"]

    app.run(**configuration['flask_options'])
Exemple #11
0
def articleView(id):
    prevArt = Article.query.filter(Article.id > id).order_by(
        Article.id.asc()).first()
    nextArt = Article.query.filter(Article.id < id).order_by(
        Article.id.desc()).first()
    article = Article.query.get(id)
    article.view_num = article.view_num + 1
    db.session.add(article)
    db.session.commit()
    seo = {
        'title': title,
        'description': article.summary,
        'keywords': article.tags.strip(',')
    }
    return render_template(
        'article_view.html',
        categories=Category.query.all(),
        pageTitle=article.title + ' - ' + article.category.name,
        seo=seo,
        article=article,
        newArticles=Article.query.order_by(
            Article.created_at.desc()).limit(10),
        hotArticles=Article.query.order_by(Article.view_num.desc()).limit(10),
        prevArt=prevArt,
        nextArt=nextArt)


if __name__ == '__main__':
    app.jinja_env.auto_reload = True
    app.run(debug=True, port=5000, host='0.0.0.0')
Exemple #12
0
admin = admin.Admin(app, name=u'Deploy Admin')
admin.add_view(sqla.ModelView(Host, db.session, name=u"主机"))

#注册bp
app.register_blueprint(deploy_bp, url_prefix="")



@app.route('/')
def index():
    return redirect("/deploy")

@app.before_request
def before_request():
    print "-- in blue_print app"

@app.errorhandler(Exception)
def exception_handler(e):
    exc_type, exc_value, exc_traceback = sys.exc_info()
    info = traceback.format_exception(exc_type, exc_value, exc_traceback)
    err_msg = "\n".join(info)
    print err_msg

@app.errorhandler(404)
def page_not_found(e):
        return render_template('404.html'), 404

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=config.PORT, debug=True)
Exemple #13
0
#!/usr/bin/env python3
from base import app, parser
import random
from flask import jsonify


@app.route("/api/v1/random/float")
@app.route("/api/v1/random/float/")
def random_float():
    data = {"random": random.random()}
    return jsonify(data)


if __name__ == "__main__":
    args = parser.parse_args()
    app.run(port=args.port, host="0.0.0.0")
Exemple #14
0
                         status=exception.status_code)


from models.base import db

@app.middleware('response')
async def after_response(request, response):
    try:
        if not db.is_closed():
            db.close()
    except:
        error_logger.error()

from base import set_show_id_by_id,get_id_by_show_id
@app.listener('before_server_start')
def before_start(app, loop):
    app.set_show_id_by_id = set_show_id_by_id
    app.get_id_by_show_id = get_id_by_show_id
    log.info("SERVER STARTING")


import sys
if __name__ == '__main__':

    try:
        port = int(sys.argv[1])
    except:
        port = 8001

    app.run(host="0.0.0.0", port=port, debug=True)
Exemple #15
0
from base import app, db

from flask_restful import Api
from sample.sample import Todo, TodoList
from auth.auth import CreateUser

api = Api(app)
api.add_resource(TodoList, '/todos')
api.add_resource(Todo, '/todos/<todo_id>')
api.add_resource(CreateUser, '/user')

if __name__ == '__main__':
    with app.app_context():
        from base import models  # noqa
        db.create_all()
    app.run(debug=True)
from base import app

app.run(threaded=True, debug=True)
Exemple #17
0
from base import app

if __name__ == '__main__':
    app.run(threaded=True, debug=True, port=8899)
Exemple #18
0
def serve():
    app.run()
Exemple #19
0
	print score
	#print db.execute('select ? from coders where username = ?', [prob_code, session['username']]).fetchone()
	if (prob_code == 'prob1'):
		mytime = str(db.execute('select prob1 from coders where username = ?', [session['username']]).fetchone()[0])
	elif (prob_code == 'prob2'):
		mytime = str(db.execute('select prob2 from coders where username = ?', [session['username']]).fetchone()[0])
	elif (prob_code == 'prob3'):
		mytime = str(db.execute('select prob3 from coders where username = ?', [session['username']]).fetchone()[0])
	
	print mytime
	#print "mytime = ", mytime
	if code == 1:
		if str(mytime) == '0':
			score += 100
			print score
			if (prob_code == 'prob1'):
				db.execute('update coders set prob1 = ? where username = ?', [str(time.time()), session['username']])
			elif (prob_code == 'prob2'):
				db.execute('update coders set prob2 = ? where username = ?', [str(time.time()), session['username']])
			elif (prob_code == 'prob3'):
				db.execute('update coders set prob3 = ? where username = ?', [str(time.time()), session['username']])
	else:
		score -= 10
	db.execute('update coders set score = ? where username = ?', [score, session['username']])
	db.commit()

from base import app

if __name__ == '__main__':
	app.run('0.0.0.0')
Exemple #20
0
from flask import Flask, redirect
from base import app
import dashboard
import servers
import config


@app.route('/')
def hello():
    return redirect('/dashboard')


if __name__ == '__main__':
    app.run(host=config.server_listen['ADDRESS'],
            port=config.server_listen['PORT'],
            use_reloader=False,
            debug=True,
            threaded=True)
Exemple #21
0
import os
from base import app

port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
Exemple #22
0
    return render_template('login.html',
                           csrf_token=flask_session.get('csrf_token'),
                           google_client_id=GOOGLE_CLIENT_ID,
                           github_client_id=GITHUB_CLIENT_ID,
                           fb_client_id=FB_CLIENT_ID)


@app.route('/logout')
@requires_auth
def logout_view():
    auth.logout()
    flash("You have been logged out successfully")
    return redirect(url_for('dashboard'))


@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404


@app.errorhandler(401)
def unauthorized_view(e):
    return redirect(url_for('login_view'))


if __name__ == '__main__':
    app.env = app.config.get('ENV', 'production')
    app.debug = app.config.get('DEBUG', False)

    app.run(host='0.0.0.0', port=app.config.get('PORT'))
@app.route('/chat')
def end_point():
    try:
        # To chatterbot
        question = request.args.get('question')
        bot_response = str(bot.get_response(question))
        code = bot_response.split(',')[0]
        response = bot_response.split(',')[1]
        # Call code checker.
        return code_checker(code, response)
    except Exception, e:
        return code_checker('0', bot_response)


@app.route('/set')
def set():
    #import pdb; pdb.set_trace()
    key = request.args.get('key')
    value = request.args.get('value')
    SESSION[key] = value
    bot_response = str(bot.get_response(key))
    code = bot_response.split(',')[0]
    response = bot_response.split(',')[1]
    # Update corpus question = key and answer = code, response.
    return code_checker(code, response)


if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True, port=8080)
Exemple #24
0
from base import app
from base.routes import *
from models.hardware import Hardware
import os
# from flask import Flask, render_template,send_from_directory,request, jsonify, make_response
# from flask_cors import CORS

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

if __name__ == "__main__":
    app.run(host='0.0.0.0')

    # hardware = Hardware(
    #         hardware_name="HWSet1",
    #         price_per_unit="20",
    #         total_count="10",
    #         available_count="10",
    #         extra_time_rate="30"
    # )
    # hardware.save()
    # hardware = Hardware(
    #         hardware_name="HWSet2",
    #         price_per_unit="10",
    #         total_count="25",
    #         available_count="25",
    #         extra_time_rate="15"
    # )
    # hardware.save()
    # hardware = Hardware(
Exemple #25
0
from base import app

if __name__ == '__main__':
    app.run(debug=True)
Exemple #26
0
from base import app

if __name__ == '__main__':
    app.run(debug=True, threaded=True, port=9870)
Exemple #27
0
from base import app

if __name__ == '__main__':
    import argparse
    parser = argparse.ArgumentParser(description='Development Server Help')
    parser.add_argument("-d", "--debug", action="store_true", dest="debug_mode",
        help="run in debug mode (for use with PyCharm)", default=False)
    parser.add_argument("-p", "--port", dest="port",
        help="port of server (default:%(default)s)", type=int, default=5000)

    cmd_args = parser.parse_args()
    app_options = {"port": cmd_args.port }

    if cmd_args.debug_mode:
        app_options["debug"] = True
        app_options["use_debugger"] = False
        app_options["use_reloader"] = False

    app.run(**app_options)
import sys

from base import app, api, db

if __name__ == "__main__":
    if len(sys.argv) > 1 and sys.argv[1] == 'test_connection':
        try:
            session = db.create_scoped_session()
            session.execute('SELECT 1')
        except:
            raise
        else:
            print("connection is all right")
            exit(0)

    print(sys.argv)
    try:
        port = int(sys.argv[1])
    except:
        port = 8000
    app.run(port=port)
Exemple #29
0
from config import IP_HOST, IP_PORT
from base import app
from views import *

if __name__ == '__main__':
    app.run(host=IP_HOST, port=IP_PORT, debug=True)
from base import app

if __name__ == '__main__':
    app.run()
Exemple #31
0
import threading
import os
import asyncio

from base import app

if __name__ == "__main__":
    print("Flask server starting ...")
    app.run(host="0.0.0.0", debug=True, use_reloader=True)