Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_add_template_test_with_template(self):
bp = flask.Blueprint('bp', __name__)
def boolean(value):
return isinstance(value, bool)
bp.add_app_template_test(boolean)
app = flask.Flask(__name__)
app.register_blueprint(bp, url_prefix='/py')
@app.route('/')
def index():
return flask.render_template('template_test.html', value=False)
rv = app.test_client().get('/')
self.assert_in(b'Success!', rv.data)
from flask import Blueprint, redirect, url_for, render_template
from .. import get_app
main = Blueprint('main', __name__)
@main.route('/', methods=['GET'])
def index():
"""Redirect home page to docs page."""
return redirect(url_for('api.index'))
@main.route('/docs/', methods=['GET'])
def docs(endpoint):
"""Document page for an endpoint."""
api = {
'endpoint': endpoint,
'methods': [],
'doc': '',
'url': '',
# along with this program. If not, see .
"""JSON based public APIs for the amaGama translation memory server"""
from json import dumps
from flask import Blueprint, abort, current_app, request
from werkzeug.datastructures import Headers
# Let's encourage caching for an hour:
cache_headers = Headers()
cache_headers['Cache-Control'] = "max-age=3600, public"
# Create the blueprints.
read_api = Blueprint('read_api', __name__)
write_api = Blueprint('write_api', __name__)
@read_api.route('///unit/', methods=('GET', ))
def translate_unit_get(slang, tlang):
"""Return the translations for the specified unit.
This actually internally redirects to the view that handles
///unit/ GET requests.
"""
return get_uid_and_call(translate_unit, slang, tlang)
@write_api.route('///unit/', methods=('POST', ))
def update_unit_get(slang, tlang):
"""Alter the unit on the DB using the provided data.
from flask import (
Blueprint, render_template
)
bp = Blueprint('main', __name__)
@bp.route('/')
def index():
return render_template('main/index.html',
title='Flask-PWA')
from flask import Blueprint
from api.models.BusStop import BusStop
from api.core import create_response, serialize_list, logger
from api.scrapers.bus_stops import scrape
import requests
busStop = Blueprint("busStop", __name__)
@busStop.route("/bus-stops", methods=["GET"])
def get_busStop():
"""
GET function for retrieving BusStop objects
"""
response = [busStop.to_mongo() for busStop in BusStop.objects]
response = {"busStops": response}
logger.info("BUSSTOPS: %s", response)
return create_response(data=response)
@busStop.route("/bus-stops", methods=["POST"])
def scrape_stops():
"""
"""Register all namespaces and import API's from controllers."""
from flask import Blueprint
from flask_restx import Api
from c3po.api.controller.feed_controller import feed_ns
api_bp = Blueprint("api", __name__)
api = Api(
api_bp,
title="Flask-RESTPlus common backend for LTT-KGP",
version="1.0",
description="a boilerplate for flask restplus web service",
)
api.add_namespace(feed_ns, path="/v1/feed")
from flask import request, jsonify, Blueprint
from flask_login import login_required, login_user, current_user, logout_user
from models import User
bp = Blueprint('blueprint', __name__, template_folder='templates')
@bp.route("/", methods=["GET"])
def index():
return jsonify(message="Hello World!"), 200
@bp.route("/login", methods=["POST"])
def login():
json_payload = request.get_json()
user_entry = User.get(json_payload['username'])
if (user_entry):
user = User(*user_entry)
if (user.password == json_payload['password']): # not for prod
login_user(user)
return jsonify(isLoggedIn=current_user.is_authenticated), 200
import json
from flask import Blueprint, render_template, request, redirect, url_for
from models.alert import Alert
from models.store import Store
from models.item import Item
alert_blueprint = Blueprint('alerts', __name__)
@alert_blueprint.route('/')
def index():
alerts = Alert.all()
return render_template('alerts/index.html', alerts=alerts)
@alert_blueprint.route('/new', methods=['GET', 'POST'])
def create_alert():
if request.method == 'POST':
item_url = request.form['item_url']
store = Store.find_by_url(item_url)
item = Item(item_url, store.tag_name, store.query)
item.load_price()
:license: BSD (See LICENSE for details)
"""
# Imports outside bombolone
import re
from flask import Blueprint, request, session, g, Response, render_template, url_for, redirect
from pymongo import ASCENDING, DESCENDING
from pymongo.objectid import ObjectId
# Imports inside bombolone
from decorators import check_authentication, check_admin
from helpers import create_password
from upload import upload_file
MODULE_DIR = 'admin/pages'
pages = Blueprint('pages', __name__)
@pages.route('/admin/pages/')
@check_authentication
def overview():
"""
"""
pages = g.db.pages.find()
return render_template( MODULE_DIR+'/index.html', **locals() )
def request_form(page):
"""
"""
form = request.form
# Standard Library
from uuid import UUID
# 3rd Party
from flask import Blueprint, current_app, g, jsonify, make_response, request, url_for
# Fastlane
from fastlane.helpers import loads
from fastlane.models import JobExecution, Task
bp = Blueprint("enqueue", __name__) # pylint: disable=invalid-name
def get_details():
try:
details = request.get_json()
except Exception:
details = None
if details is None and request.get_data():
try:
details = loads(request.get_data())
except Exception:
details = None
return details