本文整理匯總了Python中flask.ext.api.FlaskAPI.config["DEFAULT_RENDERERS"]方法的典型用法代碼示例。如果您正苦於以下問題:Python FlaskAPI.config["DEFAULT_RENDERERS"]方法的具體用法?Python FlaskAPI.config["DEFAULT_RENDERERS"]怎麽用?Python FlaskAPI.config["DEFAULT_RENDERERS"]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flask.ext.api.FlaskAPI
的用法示例。
在下文中一共展示了FlaskAPI.config["DEFAULT_RENDERERS"]方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FlaskAPI
# 需要導入模塊: from flask.ext.api import FlaskAPI [as 別名]
# 或者: from flask.ext.api.FlaskAPI import config["DEFAULT_RENDERERS"] [as 別名]
from flask.ext.api import FlaskAPI
from flask.ext.api.exceptions import ParseError
from marshmallow import ValidationError
import schema
import models
app = FlaskAPI(__name__)
models.db.init_app(app)
app.config.from_object("settings.Config")
app.config["DEFAULT_RENDERERS"] = [
"flask.ext.api.renderers.JSONRenderer",
"flask.ext.api.renderers.BrowsableAPIRenderer",
]
@app.route("/query", methods=["GET", "POST"])
def stocks():
"""Simplest possible implementation of this algorithm."""
s = schema.QuerySetSchema(strict=True)
try:
q = s.load(request.data)
except ValidationError as err:
raise ParseError(detail="Bad fields: {}".format(err.field_names))
return dict(data=q)
示例2: FlaskAPI
# 需要導入模塊: from flask.ext.api import FlaskAPI [as 別名]
# 或者: from flask.ext.api.FlaskAPI import config["DEFAULT_RENDERERS"] [as 別名]
from flask.ext.api import FlaskAPI, exceptions, status
from flask import request, send_file, render_template
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import update
import yaml
from datetime import datetime
app = FlaskAPI(__name__)
db = SQLAlchemy()
db.init_app(app)
config_file = open('config.yaml', 'r')
config = yaml.load(config_file)
app.config["SQLALCHEMY_DATABASE_URI"] = config["SQLALCHEMY_DATABASE_URI"]
app.config["DEBUG"] = config["DEBUG"]
app.config["SECRET_KEY"] = config["SECRET_KEY"]
app.config["DEFAULT_RENDERERS"] = config["DEFAULT_RENDERERS"]
meal_ingredient = db.Table('meal_ingredient',
db.Column('meal_id', db.Integer, db.ForeignKey('meal.id'), nullable=False),
db.Column('ingredient_id', db.Integer, db.ForeignKey('ingredient.id'), nullable=False),
db.PrimaryKeyConstraint('meal_id', 'ingredient_id'))
def init_db():
db.init_app(app)
db.create_all()
class Ingredient(db.Model):
id = db.Column(db.Integer, primary_key=True, unique=True)
created = db.Column(db.DateTime)