Spaces:
Runtime error
Runtime error
File size: 1,048 Bytes
8397f09 718633d 8397f09 |
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 |
import os
from flask import Flask
from flask_jwt_extended import JWTManager
from flask_cors import CORS
from .routes.routes import main # Changed to relative import
import logging
jwt = JWTManager()
def create_app(config_object):
app = Flask(__name__)
app.config.from_object(config_object) # Use from_object to load config from the class instance
# Configure logging
app.logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
app.logger.addHandler(handler)
# π Initialize JWT
jwt.init_app(app)
# π§ Enable CORS for all origins and all methods (development only)
CORS(
app,
resources={r"/*": {"origins": "*"}},
supports_credentials=True,
allow_headers=["Content-Type", "Authorization"],
methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"]
)
# π¦ Register routes
app.register_blueprint(main)
return app
|