예제 #1
0
def init_app(name: str, config: str = "development"):
    app = Flask(name)
    app = load_config(app=app, config_type=config)
    database.init_app(app)
    CORS(app)

    swagger = Swagger(app,
                      template={
                          "openapi": "3.0.0",
                          "info": {
                              "title": "crayon Task Backend API",
                              "version": "1.0",
                              "description": "API for Crayon",
                              "contact": {
                                  "responsibleOrganization": "Praveen Kumar",
                                  "email": "*****@*****.**",
                                  "url": "thepraveenpkg.firebaseapp.com",
                              },
                          },
                          "produces": [
                              "application/json",
                          ],
                      })

    with app.app_context():
        from modules.newsfeed.upload import nw

        app.register_blueprint(nw)

    return app
예제 #2
0
def create_app():
    app = Flask(__name__)
    app.config[
        'SQLALCHEMY_DATABASE_URI'] = 'mysql://*****:*****@104.198.224.97/swe_travels'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    database.init_app(app)

    return app
예제 #3
0
def initialize_flask_app(name: str, config: str = 'development') -> Flask:
    app = Flask(name)
    app = load_config(app=app, config_type=config)

    database.init_app(app=app)

    CORS(app)

    # initializing swagger
    swagger = Swagger(app, template={
        "openapi": "3.0.0",
        "info": {
            "tittle": "Bix Backend API",
            "version": "1.0",
            "description": "API For Bix",
            "contact": {
                "responsibleOrganization": "BIX IT ACADEMY",
                "email": "*****@*****.**",
                "url": "bixitacademy.com"
            },
        },
        "produces": [
            "application/json",
        ],
    })

    # Initializing JWT token management
    jwt = JWTManager(app)

    init_logger()

    with app.app_context():
        pass
        # config modules here

    # app.register_blueprint()  # module blueprint
    # app.register_blueprint()  # module blueprint

    return app
예제 #4
0
# coding:utf-8
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from flask import Flask
from slackeventsapi import SlackEventAdapter
from settings import HOST, PORT, SQLALCHEMY_DATABASE_URI, SQLALCHEMY_TRACK_MODIFICATIONS, SLACK_SIGNING_SECRET, CHATBOT_ENDPOINT, CHATBOT_SECRET_KEY
from models import database as db
from modules import authorize, handle_message

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = SQLALCHEMY_TRACK_MODIFICATIONS
# Create a dictionary to represent a database to store our token
db.init_app(app)
db.create_all(app=app)

# Route for Oauth flow to redirect to after user accepts scopes
app.route('/authorize', methods=['GET', 'POST'])(authorize)

# Bind the Events API route to your existing Flask app by passing the server
# instance as the last param, or with `server=app`.
slack_events_adapter = SlackEventAdapter(SLACK_SIGNING_SECRET, '/slack/events',
                                         app)
slack_events_adapter.on('message')(handle_message)

if __name__ == '__main__':
    print('start application')
    app.run(host=HOST, port=PORT, debug=True)
예제 #5
0
from text_rank import TextRank

debug = os.environ.get("DEBUG", "false").lower() == "true"
ENV = os.environ.get("ENV", "dev")
DD_API_URL = "https://api.datadoghq.com/api/v1/"

log = logging.getLogger("summarizer_server")

app = Flask(__name__)
textrank = TextRank()
textrank.setup()

# db setup
settings = Settings()
app.config.from_object(settings)
database.init_app(app)

engine = create_engine(settings.SQLALCHEMY_DATABASE_URI)
database.metadata.create_all(engine)

accountservice = AccountService()
feedbackservice = FeedbackService()


@app.route("/v1/")
def index():
    return "Summarizer API v1"


@app.route("/api/extract", methods=["POST"])  # deprecated
@app.route("/v1/extract", methods=["POST"])