Beispiel #1
0
def create_app():

    app = Flask(__name__)
    app.config.from_object(config)

    if app.config['ENVIRONMENT'] == 'production' and \
            app.config['SENTRY_CONFIG']['dsn']:
        Sentry(app)

    CORS(app)

    @app.errorhandler(500)
    def bad_things_happens(error):
        error_id = None
        if app.config['SENTRY_CONFIG']['dsn']:
            error_id = g.sentry_event_id

        return jsonify({
            'message': 'Internal server error.',
            'error_id': error_id
        })

    app.register_blueprint(api, url_prefix='/v0')

    return app
Beispiel #2
0
def create_app(test_config=None):
    # create and configure the app
    app = Flask(__name__, instance_relative_config=True)
    # to generate truly random secrets use
    # import secrets
    # print(secrets.token_urlsafe(32))

    # to use sessions the secret_key has to be set
    # to generate csrf token sessions are required
    app.config.from_mapping(
        WTF_CSRF_SECRET_KEY=os.environ.get('WTF_CSRF_SECRET_KEY'),
        SECRET_KEY=os.environ.get('SECRET_KEY'))

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile('config.py', silent=True)
    else:
        # load the test config if passed in
        app.config.from_mapping(test_config)

    # ensure the instance folder exists
    try:
        os.mkdir(app.instance_path)
    except OSError:
        pass

    CORS(app,
         origins=[os.environ.get('ALLOWED_ORIGIN')],
         supports_credentials=True)
    blueprints.init_app(app)

    create_client(app.logger)
    create_admin_user(app.logger)
    return app
Beispiel #3
0
def create_app(config_name):
    app = Flask(__name__)
    CORS(app, supports_credentials=True, origins=[
        'http://localhost:8000',
    ])
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    from app.api import api_bp
    app.register_blueprint(api_bp, url_prefix='/api')

    return app
Beispiel #4
0
def start_server(params):
    global args
    LogHelper.log('CREATING SERVER')
    config_server(params)
    app = Flask(args['name'])
    CORS(app)
    app.add_url_rule('/',
                     '/',
                     honeypot,
                     methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])
    app.add_url_rule('/<path:path>',
                     '/<path:path>',
                     honeypot,
                     methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])
    args['app'] = app
    run_server()
from flask import Flask, request, json
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
from flask_jwt_extended import (create_access_token, create_refresh_token, JWTManager)
from marshmallow_enum import EnumField
from flask_cors.extension import CORS
from datetime import datetime
import enum

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
db = SQLAlchemy(app)
ma = Marshmallow(app)
jwt = JWTManager(app)
app.config['JWT_SECRET_KEY'] = 'boost-is-the-secret-of-our-app'
CORS(app)

## MODELOS & ESQUEMAS
#usuario
class Usuario(db.Model):
    id = db.Column(db.Integer, primary_key=1)
    email = db.Column(db.String(120), unique=1, nullable=0)
    usuario = db.Column(db.String(80), unique=1, nullable=0)
    contrasena = db.Column(db.String(120), nullable=0)
    #Relaciones
    eventos = db.relationship('Evento', backref='usuario', lazy=1)
class UsuarioSchema(ma.Schema):
    class Meta:
        fields = ("id", "email", "usuario")
usuarioSchema = UsuarioSchema()
usuariosSchema = UsuarioSchema(many=1)
from app.utils.storage import Minio
from flask import Flask, jsonify, request
from flask_caching import Cache
from flask_cors.extension import CORS
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
from flask_sqlalchemy import SQLAlchemy
from flasgger.base import Swagger

# Initialize core objects

app = Flask(__name__)
app.config.from_object("config")

cache = Cache(app)
cors = CORS(app)
db = SQLAlchemy(app)
jwt = JWTManager(app)
limiter = Limiter(
    app,
    key_func=get_remote_address,
    default_limits=["100 per minute", "5 per second"],
)
mail = Mail(app)
swagger = Swagger(app)
storage = Minio(app)
rq = RQ(app)

# -- Handler
from app.handlers import (http_handler, jwt_handler, log_handler)
Beispiel #7
0
import json
import pandas as pd
from flask import Flask, jsonify
from flask_cors.extension import CORS
from db.postgresl import PropertyDAO
from model.Property import Property
from flask.globals import request
from simulator import Simulator

#start the rest api application
app = Flask(__name__)
CORS(app) #apply cors for remote connection accept

@app.route('/')
def index():
    data = {}
    data['test'] = {"self": {"href": "/test"}}
    data['get_property'] = {"self": {"href": "/prop/{propid}"}}
    data['testpost'] = {"self": {"href": "/testpost"}}
    data['simulate'] = {"self": {"href": "/simulate"}}
    
    return json.dumps(data);

@app.route('/simulate', methods=['POST'])
def simulate():
    simulator = Simulator()
    req_data = request.get_json()
    data = {'price':[req_data['price']],
        'bedrooms':[req_data['bedrooms']],
        'bath':[req_data['bath']],
        'size_sqft':[req_data['size_sqft']],
Beispiel #8
0
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
from sqlalchemy import Column, MetaData, String, Table, Boolean
from sqlalchemy.engine import create_engine
from sqlalchemy.orm import sessionmaker
import twitter
import xlsxwriter

import numpy as np
import pandas as pd


app = Flask(__name__)
CORS(app, supports_credentials=True)

metadata = MetaData()
engine = create_engine('mysql+pymysql://%s:%s@localhost/%s' % ('[redacted]', urllib.parse.quote_plus('[redacted]'), '[redacted]'),pool_recycle=3600)
urls = Table('urls',metadata,
                  Column('keyy',String),
                  Column('url',String))
users = Table('users', metadata, Column('username', String),Column('password', String),Column('email', String), Column('isAdmin', Boolean))
global latestTimestamp
latestTimestamp = None
global latestDf
latestDf = None
global latestDfText
latestDfText = None

@app.route('/api/Import', methods = ['POST']) 
Beispiel #9
0
'''
Created on 24/08/2019

@author: Gera e Ian
'''
from flask_restful import Api
from flask_cors.extension import CORS
from ston.config import webapp
from flask import jsonify
from ston.gsRetail.gsRetail import gsRetail

api = Api(webapp)
CORS(webapp, resources={r"/*": {"origins": "*"}})

# Mailer
api.add_resource(gsRetail, '/v1/gsChallengeRetail/<string:option>')
from flask import Blueprint
from flask_cors.extension import CORS

from pcapi import settings
from pcapi.routes.native import utils
from pcapi.serialization.spec_tree import ExtendedSpecTree
from pcapi.serialization.utils import before_handler

native_v1 = Blueprint("native_v1", __name__)
native_v1.before_request(utils.check_client_version)
CORS(
    native_v1,
    origins=settings.CORS_ALLOWED_ORIGINS_NATIVE,
    supports_credentials=True,
)

JWT_AUTH = "JWTAuth"

security_schemes = {
    JWT_AUTH: {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
    }
}

api = ExtendedSpecTree("flask",
                       MODE="strict",
                       before=before_handler,
                       PATH="/",
                       security_schemes=security_schemes)
Beispiel #11
0
@ui_bp.route('/swagger_ui/<path:filename>')
def serve_swagger_ui_static_files(filename):
    return flask.send_from_directory('static', filename)


@ui_bp.route('/swagger_ui.json')
def serve_swagger_ui_json():
    return utils.yaml_to_json(config.wd + '/' + config.SPEC_FN)


app.app.register_blueprint(ui_bp)

app.add_api('api.yaml')

CORS(app.app)

app.app.wsgi_app = sqltap.wsgi.SQLTapMiddleware(app.app.wsgi_app)


@click.command()
@click.option('-d', '--debug', is_flag=True)
@click.option('-p', '--port', type=click.INT, default=8000)
@click.option('-h', '--host', default='0.0.0.0')
def main(debug, port, host):
    if debug:
        app.run(host=host, port=port, debug=True)
    else:
        bjoern.run(app.app.wsgi_app, host=host, port=port)

Beispiel #12
0
@author: RAEO
'''
from flask.app import Flask
from flask_cors.extension import CORS
from flask_restful import Api
from api import routing_api
from db import mongo as mongo
from utils.createadminuser import CreateAdminUser
from utils.createdir import CreateDir
from security.security import configure_jwt
from configs import config

app = Flask(__name__,
            static_folder=config.UPLOAD_DIR,
            static_url_path='/static/profile')
cors = CORS(app, resources={r"*": {"origins": "*"}})
app.config.from_object(config)
api = Api(app)

routing_api(url_prefix='/users', api=api)

configure_jwt(app)
mongo.init_app(app)

with app.app_context():
    CreateDir.image_dir(app.config['UPLOAD_DIR'])
    CreateAdminUser.create()

if __name__ == '__main__':
    app.run()
    #app.run(debug=True)
from flask import Blueprint
from flask_cors.extension import CORS

from pcapi import settings
from pcapi.routes.native import utils

saml_blueprint = Blueprint("saml_blueprint", __name__)
saml_blueprint.before_request(utils.check_client_version)
CORS(saml_blueprint,
     origins=settings.CORS_ALLOWED_ORIGINS_NATIVE,
     supports_credentials=True)
Beispiel #14
0
import user_service
import common_service
import json
from userServiceDto import userServiceDto
from SystemException import SystemException
from SystemConstant import SystemConstant
from user_service import get_user_by_token, check_duplicate_user
from absPath import movies_image_path



app = Flask(__name__,
            static_folder = "./dist/static",
            template_folder = "./dist")
cors = CORS(app, resources={r"/common-service/*": {"origins": "*"},
                            r"/user-service/*": {"origins": "*"},
                             r"/movie-service/*": {"origins": "*"}})

app.secret_key = os.urandom(24)

exception = {}

UPLOAD_FOLDER = movies_image_path()
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

@app.route('/common-service/')
def common_service_pom():
    pom = common_service.pom_version()
    response = {
        'msg' : '{'+pom.service+', '
                +pom.version+', '
Beispiel #15
0
from flask import Blueprint
from flask_cors.extension import CORS

from pcapi import settings
from pcapi.serialization.spec_tree import ExtendedSpecTree
from pcapi.serialization.utils import before_handler


adage_iframe = Blueprint("adage_iframe", __name__)
CORS(
    adage_iframe,
    origins=settings.CORS_ALLOWED_ORIGINS_ADAGE_IFRAME,
)

JWT_AUTH = "JWTAuth"

security_schemes = {
    JWT_AUTH: {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
    }
}

api = ExtendedSpecTree(
    "flask",
    title="Pass Culture API accessed through iframe from adage clients",
    MODE="strict",
    before=before_handler,
    PATH="/",
    security_schemes=security_schemes,