DomainExpiration/app/__init__.py

31 lines
914 B
Python

import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def create_app():
# Create the Flask app and set the template folder (located in app/templates)
app = Flask(__name__, template_folder='templates')
# Configure the SQLite database
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(os.path.abspath(os.path.dirname(__file__)), 'domains.db')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# Initialize SQLAlchemy with the app
db.init_app(app)
with app.app_context():
# Import models so that they are registered with SQLAlchemy before creating tables
from app import models
db.create_all()
# Register blueprints
from app.routes.domain import domain_bp
app.register_blueprint(domain_bp)
from app.routes.ssl import ssl_bp
app.register_blueprint(ssl_bp)
return app