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_none_response(self):
app = flask.Flask(__name__)
@app.route('/')
def test():
return None
try:
app.test_client().get('/')
except ValueError, e:
self.assert_equal(str(e), 'View function did not return a response')
pass
else:
self.assert_("Expected ValueError")
def test_other_encoding(self):
app = Flask(__name__)
app.config['FLATPAGES_ENCODING'] = 'shift_jis'
app.config['FLATPAGES_ROOT'] = 'pages_shift_jis'
pages = FlatPages(app)
self.assert_unicode(pages)
def test_yaml_meta(self):
pages = FlatPages(Flask(__name__))
foo = pages.get('foo')
self.assertEqual(foo.meta, {
'title': 'Foo > bar',
'created': datetime.date(2010, 12, 11),
'updated': datetime.datetime(2015, 2, 9, 10, 59, 0),
'updated_iso': datetime.datetime(2015, 2, 9, 10, 59, 0,
tzinfo=utc),
'versions': [3.14, 42],
})
self.assertEqual(foo['title'], 'Foo > bar')
self.assertEqual(foo['created'], datetime.date(2010, 12, 11))
self.assertEqual(foo['updated'],
datetime.datetime(2015, 2, 9, 10, 59, 0))
self.assertEqual(foo['updated_iso'],
datetime.datetime(2015, 2, 9, 10, 59, 0,
tzinfo=utc))
import json
from flask import Flask, request, make_response
from .sankey_view import SankeyView, Elsewhere
from .view_definition import ProcessGroup, Bundle
from .dataset import Dataset
from flask.ext.cors import CORS
app = Flask(__name__)
CORS(app)
dataset = Dataset.load('fruit_dataset.h5')
def parse_json(s):
o = json.loads(s)
o['bundles'] = [Bundle(x['source'], x['target'], waypoints=x['waypoints'])
for x in o['bundles']]
o['process_groups'] = {x['id']: ProcessGroup(x['rank'], x['depth'], query=x['selection'].split(','),
reversed=x.get('reversed', False))
for x in o['nodes']}
return o
@app.route("/view")
def server(pipeline_res, host, port, debug=True):
app = Flask(__name__)
CORS(app)
# @app.route('/', methods=['GET'])
# @app.route('/index.html', methods=['GET'])
# def root():
# print("got to root")
# return app.send_static_file('static/index.html')
@app.route('/graphs', methods=['GET'])
@cross_origin()
def graphs():
# data = [d.graph.as_rdf() for d in pipeline_res["pre-process"]["train"].data]
data = [d.graph.as_rdf() for d in pipeline_res["test-corpus"].data]
return jsonify(data)
@app.route('/plans/', methods=['POST'])
import os
import sys
import adal
import json
from flask import Flask, render_template
import requests
import util
import logging
log = logging.getLogger()
util.get_settings()
log.debug("Env vars: \n" + str(os.environ))
app = Flask(__name__, static_url_path='/static')
# Make the WSGI interface available at the top level so wfastcgi can get it.
wsgi_app = app.wsgi_app
@app.route('/api/token')
def get_token():
context = adal.AuthenticationContext(
os.environ['PBI_AUTHORITY'],
validate_authority=True,
api_version=None)
token_response = context.acquire_token_with_username_password(
os.environ['PBI_RESOURCE'],
os.environ['PBI_USERNAME'],
os.environ['PBI_PASSWORD'],
os.environ['PBI_CLIENTID']
import sys
import werkzeug
from flask import flash
from flask import Flask
from flask import jsonify
from flask import redirect
from flask import request
root_dir = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(root_dir, '../src'))
from reader._app.api_thing import APIThing, APIError
app = Flask(
__name__,
template_folder='../src/reader/_app/templates',
static_folder='../src/reader/_app/static',
)
app.secret_key = 'secret'
@app.route('/')
def root():
with open(os.path.join(root_dir, 'jscontrols.html')) as f:
template_string = f.read()
return app.jinja_env.from_string(template_string).render()
form = APIThing(app, '/form', 'form')
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
from pprint import pprint
from queue import PriorityQueue
from threading import Thread
from flask import Flask, request, jsonify
from convlab.modules.e2e.multiwoz.Sequicity.model import main as sequicity_load
rgi_queue = PriorityQueue(maxsize=0)
rgo_queue = PriorityQueue(maxsize=0)
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def process():
try:
in_request = request.json
print(in_request)
except:
return "invalid input: {}".format(in_request)
rgi_queue.put(in_request)
rgi_queue.join()
output = rgo_queue.get()
print(output['response'])
rgo_queue.task_done()
return jsonify(output)
def create_app(**kwargs):
"""Creates a new Flask app using the Factory Pattern"""
app = Flask(__name__)
app.config.update(kwargs)
# extensions
ext.configure(app) # <-- registro dinâmico das extensões
# blueprints
blueprints.configure(app) # <-- registro dinâmico dos blueprints
return app
#coding:utf8
from flask import Flask,render_template
from flask_sqlalchemy import SQLAlchemy
import pymysql,os
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql+pymysql://root:zhangsan@127.0.0.1/movie"
app.config["SQLALCHEMY_TRACK_MODIFICATION"] = True
app.config["SECRET_KEY"]="ZHANGSan"
app.config["UP_DIR"]= os.path.join(os.path.abspath(os.path.dirname(__file__)),'static/upload/')
app.debug = True
db = SQLAlchemy(app)
from app.home import home as home_blueprint
from app.admin import admin as admin_blueprint
app.register_blueprint(home_blueprint)
app.register_blueprint(admin_blueprint,url_prefix="/admin")
@app.errorhandler(404)
def page_not_found(error):