-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
49 lines (41 loc) · 1.43 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
from flask import Flask, jsonify
from flask_smorest import Api
from flask_jwt_extended import JWTManager
from flask_migrate import Migrate
from dotenv import load_dotenv
import redis
from rq import Queue
from db import db
from blocklist import BLOCKLIST
import models
from models.user import UserModel
from redis import Redis
from resources.user import blp as UserBlueprint
def create_app(db_url=None):
app = Flask(__name__)
load_dotenv()
# connection = redis.from_url(
# os.getenv("REDIS_URL")
# )
connection=Redis(host='redis',port=6379)
# connection=Redis(host='rq_worker',port=6379)
app.queue = Queue("emails", connection=connection)
app.config["PROPAGATE_EXCEPTIONS"] = True
app.config["API_TITLE"] = "Stores REST API"
app.config["API_VERSION"] = "v1"
app.config["OPENAPI_VERSION"] = "3.0.3"
app.config["OPENAPI_URL_PREFIX"] = "/"
app.config["OPENAPI_SWAGGER_UI_PATH"] = "/swagger-ui"
app.config["OPENAPI_SWAGGER_UI_URL"] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist/"
app.config["SQLALCHEMY_DATABASE_URI"] = db_url or os.getenv("DATABASE_URL", "sqlite:///data.db")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db.init_app(app)
migrate = Migrate(app, db)
api = Api(app)
#@app.before_first_request
# @app._got_first_request
# def create_tables():
# db.create_all()
api.register_blueprint(UserBlueprint)
return app