# default settings NAME = 'localhost' DATABASE = 'script-server.db' LOGFILE = 'script-server.log' SECRET_KEY = os.urandom(24) PORT = 5000 COMMAND = '/usr/bin/python' ARGS = [] MAX_RUNNING = 1 # create Flask app app = Flask(__name__) bcrypt = Bcrypt(app) app.config.from_object(__name__) app.config.from_pyfile('script-server.cfg', silent=True) api.add_api(app) app.register_blueprint(ui) # set up JobManager object job_manager = jobs.JobManager(app.config['COMMAND'], app.config['ARGS'], app.config['DATABASE'], app.config['MAX_RUNNING']) # before each request: set up 'g', open database connection @app.before_request def before_request(): g.config = app.config g.version = version g.job_manager = job_manager g.db = database.connect(app.config['DATABASE'])
def initialize_app(flask_app): configure_app(flask_app) CORS(flask_app) add_api(flask_app)
# default settings NAME = 'localhost' DATABASE = 'script-server.db' LOGFILE = 'script-server.log' SECRET_KEY = os.urandom(24) PORT = 5000 COMMAND = '/usr/bin/python' ARGS = [] MAX_RUNNING = 1 # create Flask app app = Flask(__name__) bcrypt = Bcrypt(app) app.config.from_object(__name__) app.config.from_pyfile('script-server.cfg', silent=True) api.add_api(app) app.register_blueprint(ui) # set up JobManager object job_manager = jobs.JobManager(app.config['COMMAND'], app.config['ARGS'], app.config['DATABASE'], app.config['MAX_RUNNING']) # before each request: set up 'g', open database connection @app.before_request def before_request(): g.config = app.config g.version = version g.job_manager = job_manager
def initialize_app(flask_app): # pragma: no cover configure_app(flask_app) CORS(flask_app) add_api(flask_app)
from flask import Flask from flask import render_template from db import get_user_faces from api import add_api app = Flask(__name__) add_api(app) @app.route('/') @app.route('/<photo_id>') def view_home(photo_id=None): photo_url = None if not photo_id: photo_id = "" else: user_faces = get_user_faces(photo_id) if user_faces: photo_url = user_faces[0]['face_url'] return render_template( 'home.html', photo_id=photo_id, photo_url=photo_url, ) @app.route('/about') def view_about(): return render_template('about.html')