本文整理汇总了Python中flask.ext.api.FlaskAPI类的典型用法代码示例。如果您正苦于以下问题:Python FlaskAPI类的具体用法?Python FlaskAPI怎么用?Python FlaskAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FlaskAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_manager
def create_manager(case_api_client=CaseApi):
app = FlaskAPI(__name__)
app.config.from_pyfile('config.py')
manager = Manager(app)
app.register_blueprint(helloworld.blueprint)
app.register_blueprint(deed.blueprint(case_api_client()))
db.init(app, manager)
return manager
示例2: create_app
def create_app(config_name):
app = FlaskAPI(__name__)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
db.init_app(app)
from api.v1 import api as api_blueprint
app.register_blueprint(api_blueprint, url_prefix='/api/v1')
return app
示例3: create_manager
def create_manager():
app = FlaskAPI(__name__)
app.config.from_pyfile('config.py')
app.register_blueprint(helloworld.blueprint)
app.register_blueprint(home.blueprint)
app.register_blueprint(case.blueprint)
app.register_blueprint(borrower.blueprint)
app.register_blueprint(property.blueprint)
app.register_blueprint(land_registry.blueprint)
manager = Manager(app)
db.init(app, manager)
return manager
示例4: create_manager
def create_manager(deed_api_client=DeedApi):
app = FlaskAPI(__name__)
app.config.from_pyfile('config.py')
app.register_blueprint(helloworld.blueprint)
app.register_blueprint(key.blueprint)
app.register_blueprint(sign.blueprint(deed_api_client()))
manager = Manager(app)
db.init(app, manager)
return manager
示例5: FlaskAPI
#!/usr/bin/python
#query = 'Fist Fight'
#print(youtubeSearch(query))
from flask.ext.api import FlaskAPI
from flask import jsonify, request
from ytsearch import youtubeSearch
#initialize server
app = FlaskAPI(__name__)
@app.route('/')
def index():
all_args = request.args.lists()
query = request.args['q']
video = youtubeSearch(query)
return jsonify(video)
app.run('0.0.0.0', 5000)
示例6: FlaskAPI
from flask.ext.api import FlaskAPI
from flask import request
from flask.ext.cors import CORS
import sys
if "m" not in sys.argv:
from memorydb.DB import *
else:
from mongoDB.DB import *
app = FlaskAPI(__name__)
CORS(app)
@app.route("/api/prices", methods=["GET"])
def prices():
id = request.args.get("id")
return DB.getprices(id)
@app.route("/api/prices", methods=["POST"])
def upsertprices():
data = request.data
DB.upsertprices(data)
return ""
@app.route("/api/sales", methods=["POST"])
def upsertsales():
data = request.data
DB.upsertsales(data)
示例7: FlaskAPI
import random
import sys
import uuid
from flask import render_template, url_for, abort, send_file
from flask.ext.api import FlaskAPI
from flask.ext.api.decorators import set_renderers
from flask.ext.api.renderers import HTMLRenderer
from helpers.parsers import CoOccurrenceMatrixParser, JsonParser
# Data from external modules
from data import dendrogram
from examples import example_types
app = FlaskAPI(__name__)
@app.route("/data/score-display/")
def data_score_display():
"""
Missing docstring.
"""
return send_file("../data/scores/Absalon-fili-mi_Josquin-Des-Prez_file5.mei")
@app.route("/data/pie-chart/")
def data_pie_chart():
"""
Missing DOCSTRING.
Please tell me what this function does...
"""
return [
示例8: FlaskAPI
__author__ = 'Alec Nunn'
import sqlite3
from flask.ext.api import FlaskAPI
from flask import _app_ctx_stack, stream_with_context, Response
import time
from common import *
app = FlaskAPI(__name__)
def get_db():
"""
Opens a connection to the database and returns the database as an object
Don't forget to close the connection when you are finished please and
thank you
"""
sqlite_db = sqlite3.connect('test.db')
sqlite_db.row_factory = sqlite3.Row
sqlite_db.create_function('inet_ntoa', 1, get_ip)
sqlite_db.create_function('inet_aton', 1, get_dec)
return sqlite_db
def stream_query(q, args):
"""
Queries the DB
Returns a generator that "streams" the query results.
Useful for streaming large data-sets.
示例9: FlaskAPI
from flask import request
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))
示例10: Path
from flask.ext.api.renderers import HTMLRenderer
from flask.ext.api.exceptions import APIException
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager, login_user, logout_user, current_user, login_required
from flask.ext.wtf import Form
from wtforms import TextField, BooleanField
from wtforms.validators import Required
from sqlalchemy import Column, Integer, String, DateTime, Boolean, desc, ForeignKey
from unipath import Path
import bleach
import filters
TEMPLATE_DIR = Path(__file__).ancestor(1).child("templates")
app = FlaskAPI(__name__, template_folder=TEMPLATE_DIR)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
app.config['SECRET_KEY'] = 'you-will-never-guess'
db = SQLAlchemy(app)
lm = LoginManager()
lm.init_app(app)
lm.login_view = 'login'
filters.init_app(app)
class LoginForm(Form):
username = TextField('username', validators = [Required()])
示例11: FlaskAPI
from flask.ext.api import FlaskAPI
from application.main.controllers import main
from application.admin.controllers import admin
app = FlaskAPI(__name__)
app.register_blueprint(main, url_prefix='/')
app.register_blueprint(admin, url_prefix='/admin')
示例12: FlaskAPI
from flask import Flask, request, render_template
from flask.ext.api import FlaskAPI, status
from flask.ext.cors import CORS
#when we have secret keys and such turn this back on
import config
app = FlaskAPI(__name__)
app.config['SECRET_KEY'] = 'super-secret'
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
# will pull config options from config.py
#app.config.from_object(config)
示例13: FlaskAPI
from flask.ext.api import FlaskAPI # importa la clase de flaskapi
from conf.config import LocalConfig # importa la configuracion la clase que se le da
from modules.authentication import authentication, auth
from modules.authors import authors
from modules.enera import enera
from modules import mongo
import os
from flask import Flask, url_for
from flask import Flask, render_template, url_for
from werkzeug.routing import Map, Rule, NotFound, RequestRedirect, BaseConverter
from flask.ext.script import Manager
from flask import Flask, jsonify
application = FlaskAPI(__name__)
# manager = Manager(application)
if 'Hacker' in os.environ:
application.config.from_object(DevelopConfig)
else:
application.config.from_object(LocalConfig)
# Blueprint
application.register_blueprint(authentication, url_prefix='/authentication')
application.register_blueprint(authors, url_prefix='/authors')
application.register_blueprint(enera, url_prefix='/enera')
# we are going to start mongo whit this application
mongo.init_app(application)
@application.route('/')
示例14: FlaskAPI
from flask import request, url_for
from flask.ext.api import FlaskAPI, status, exceptions
import handlers as h
import tournament as tour
import rq
import os
from database import R
app = FlaskAPI(__name__)
# define api:
# tournament
# teams
# session
# add, remove, stage next games, get ranking
# teams
# add, get
# team_id
# games
# add game
# game
# score, teams
#
# Teams
# team
# members
# id
# name
# Games
# game
# teams
示例15: FlaskAPI
from ConfigFiles import *
######################################################################################################
# Global Variables.
######################################################################################################
VM_IMAGES = {} # Stores all the VM images given as input.
PM_ADDRS = {} # Stores the IPs of all available Physical Machines
VM_RUNNING = {} # Stores all the running VMs.
######################################################################################################
# Flask Application Initializer.
######################################################################################################
app = FlaskAPI(__name__)
######################################################################################################
# Homepage.
######################################################################################################
@app.route("/", methods=['GET'])
def homepage():
homeString = {}
homeString["Cloud Orchestration Layer"] = [
{
"Author" : "Mohit Jain",
"ver" : "1.0",
"Options" :
{
"List VM Types" : "http://localhost:5000/vm/types",