def run_server(args): print("Warning: this is a development server and not suitable " "for production, we recommend running under gunicorn.") from orlo import app app.config['DEBUG'] = True app.config['TRAP_HTTP_EXCEPTIONS'] = True app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False app.run(host=args.host, port=args.port, debug=True, use_reloader=True)
#!/usr/bin/env python from orlo import app app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///orlo.db' app.run(host='0.0.0.0', port=5000, debug=True)
db.session.commit() return (jsonify({'username': user.username}), 201, {'Location': url_for('get_user', id=user.id, _external=True)}) @app.route('/auth/users/<int:id>') def get_user(id): user = User.query.get(id) if not user: abort(400) return jsonify({'username': user.username}) @app.route('/auth/token') @auth.login_required def get_auth_token(): token = g.user.generate_auth_token(600) return jsonify({'token': token.decode('ascii'), 'duration': 600}) @app.route('/auth/resource') @auth.login_required def get_resource(): return jsonify({'data': 'Hello, %s!' % g.user.username}) if __name__ == '__main__': if not os.path.exists('db.sqlite'): db.create_all() app.run(debug=True)