def test_appgroup(): """Test of with_appcontext.""" @click.group(cls=AppGroup) def cli(): pass @cli.command(with_appcontext=True) def test(): click.echo(current_app.name) @cli.group() def subgroup(): pass @subgroup.command(with_appcontext=True) def test2(): click.echo(current_app.name) obj = ScriptInfo(create_app=lambda info: Keyes("testappgroup")) runner = CliRunner() result = runner.invoke(cli, ['test'], obj=obj) assert result.exit_code == 0 assert result.output == 'testappgroup\n' result = runner.invoke(cli, ['subgroup', 'test2'], obj=obj) assert result.exit_code == 0 assert result.output == 'testappgroup\n'
def test_with_appcontext(): """Test of with_appcontext.""" @click.command() @with_appcontext def testcmd(): click.echo(current_app.name) obj = ScriptInfo(create_app=lambda info: Keyes("testapp")) runner = CliRunner() result = runner.invoke(testcmd, obj=obj) assert result.exit_code == 0 assert result.output == 'testapp\n'
from keyes import Keyes from simple_page.simple_page import simple_page app = Keyes(__name__) app.register_blueprint(simple_page) # Blueprint can be registered many times app.register_blueprint(simple_page, url_prefix='/pages') if __name__=='__main__': app.run()
from keyes import Keyes from simple_page.simple_page import simple_page app = Keyes(__name__) app.register_blueprint(simple_page) # Blueprint can be registered many times app.register_blueprint(simple_page, url_prefix='/pages') if __name__ == '__main__': app.run()
from keyes import Keyes, render_template, session, request, abort, g import requests app = Keyes(__name__) app.config.update( DEBUG=True, SECRET_KEY='my development key', PERSONA_JS='https://login.persona.org/include.js', PERSONA_VERIFIER='https://verifier.login.persona.org/verify', ) app.config.from_envvar('PERSONA_SETTINGS', silent=True) @app.before_request def get_current_user(): g.user = None email = session.get('email') if email is not None: g.user = email @app.route('/') def index(): """Just a generic index page to show.""" return render_template('index.html') @app.route('/_auth/login', methods=['GET', 'POST']) def login_handler(): """This is used by the persona.js file to kick off the
def create_app(info): return Keyes("createapp")
class mod: myapp = Keyes('appname')
class mod: myapp = Keyes('appname') myapp2 = Keyes('appname2')
def create_app(info): return Keyes("keyesgroup")
class mod: application = Keyes('appname')
from __future__ import absolute_import, print_function from keyes import Keyes app1 = Keyes('app1') app2 = Keyes('app2')
from keyes import Keyes app = Keyes(__name__) app.config['DEBUG'] = True from blueprintapp.apps.admin import admin from blueprintapp.apps.frontend import frontend app.register_blueprint(admin) app.register_blueprint(frontend)
# -*- coding: utf-8 -*- """ jQuery Example ~~~~~~~~~~~~~~ A simple application that shows how Keyes and jQuery get along. :copyright: (c) 2015 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ from keyes import Keyes, jsonify, render_template, request app = Keyes(__name__) @app.route('/_add_numbers') def add_numbers(): """Add two numbers server side, ridiculous but well...""" a = request.args.get('a', 0, type=int) b = request.args.get('b', 0, type=int) return jsonify(result=a + b) @app.route('/') def index(): return render_template('index.html') if __name__ == '__main__': app.run()
from __future__ import absolute_import, print_function from keyes import Keyes testapp = Keyes('testapp')