Lerndatenbank/lernplattform/__init__.py

22 lines
1.1 KiB
Python
Raw Permalink Normal View History

2024-08-05 20:43:29 +02:00
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
2024-08-06 20:11:36 +02:00
# Initialize a new Flask app instance with the name of the current module (main).
2024-08-05 20:43:29 +02:00
app = Flask(__name__)
2024-08-06 20:11:36 +02:00
# Set the secret key for this application. This is required for session management in Flask.
# The secret key should be a cryptographically secure random value, and it's used to sign cookies.
# For more information: https://flask.palletsprojects.com/en/2.3.x/config/#SECRET_KEY
app.secret_key = 'faab0674dd8d9a4554cbeb53da2dad1414cc4c64b778e282da0b1662df7e0f85'
# Configure the database URI for SQLAlchemy. Here, it uses an SQLite database named 'learn.db'.
2024-08-05 20:43:29 +02:00
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///learn.db'
2024-08-06 20:11:36 +02:00
# Disable tracking modifications to the database, which is not necessary in this case and can improve performance.
2024-08-05 20:43:29 +02:00
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
2024-08-06 20:11:36 +02:00
# Initialize SQLAlchemy with the Flask app instance for database management.
2024-08-05 20:43:29 +02:00
db = SQLAlchemy(app)
2024-08-06 20:11:36 +02:00
# Import the routes module from the lernplattform package, which is assumed to be in the same directory.
2024-08-05 20:43:29 +02:00
import lernplattform.routes