def create_app(config_name=None, **kwargs): """ Entry point to the Flask RESTful Server application. """ from app.products.views import products_api connexion_app = connexion.FlaskApp(__name__, specification_dir='openapi/', **kwargs) app = connexion_app.app try: app.config.from_object(get_config(config_name)) except ImportError: raise Exception('Invalid Config') connexion_app.add_api('products-api-docs.yaml', resolver=RestyResolver('products')) app.register_blueprint(products_api, url_prefix='/v1.0/api/products/') managet = CouchDBManager() managet.add_document(Products) managet.setup(app) flask_injector.FlaskInjector(app=app, modules=INJECTOR_DEFAULT_MODULES.values()) app.run(port=8080) return app
'hello', 'appCodeClonefindEmailAndDocID', ''' function (doc) { if (doc.the_doc_type == 'app_code_clone_user') { emit(doc.user_email, doc._id) }; } ''') from flask import current_app as app app = Flask(__name__) app.config.update(COUCHDB_SERVER='http://*****:*****@app_code_clone.route('/cloneCognition') def cloneCognition():
from flask import render_template, jsonify, request, g, redirect, url_for, flash from app import app from flaskext.couchdb import CouchDBManager, Document, TextField, DateField, BooleanField from werkzeug.local import LocalProxy manager = CouchDBManager() #instantiate manager.setup(app) #start class NewBooking(Document): #class for interrogating CouchDB book_name = TextField() book_email = TextField() book_date = TextField() book_time = TextField() book_confirmation = BooleanField(default=False) class approvedBooking(Document): #class for interrogating CouchDB book_name = TextField() book_email = TextField() book_date = TextField() book_time = TextField() book_confirmation = BooleanField(default=False)
app = Flask(__name__) app.config.from_object(__name__) app.config.update( dict(COUCHDB_DATABASE="insults", COUCHDB_SERVER="http://localhost:5984", RIEMANN_ADDRESS="localhost:5555", BASE_URL="http://localhost:5000", STATSD_ADDRESS="localhost:8125")) app.config.from_envvar('APP_CONFIG_FILE', silent=True) api = swagger.docs(flask_restful.Api(app), apiVersion="1.0.0", basePath=app.config['BASE_URL']) # couchdb setup couchdb_manager = CouchDBManager(auto_sync=False) couchdb_manager.setup(app) riemann_client = riemann.get_client(app.config['RIEMANN_ADDRESS'], tags=[__version__]) statsd_client = metrics.statsd_client(app.config['STATSD_ADDRESS']) app.wsgi_app = riemann.wsgi_middelware( metrics.statsd_wsgi_middelware(app.wsgi_app, statsd_client), riemann_client) #app.before_first_request(init) # get a timer decorator with riemann client pre-injected timed = partial(metrics.TimerDecorator, [riemann_client.riemann_timer_reporter, statsd_client.timing])
from flaskext.uploads import (UploadSet, configure_uploads, IMAGES, UploadNotAllowed) from werkzeug.security import check_password_hash from image_classifier import ImageClassifier from webconfig import DevConfig # application app = Flask(__name__) app.config.from_object(DevConfig) # uploads uploaded_photos = UploadSet('photos', IMAGES) configure_uploads(app, uploaded_photos) # documents db = CouchDBManager() image_classifier = ImageClassifier() def unique_id(): return hex(uuid.uuid4().time)[2:-1] class Post(Document): doc_type = 'post' title = TextField() filename = TextField() location = TextField() semantic = TextField() scene = TextField()