Base scripts and templates added

This commit is contained in:
Hamit Şimşek
2025-05-30 00:07:07 +03:00
parent 73d497d4c3
commit ebd7dcc23b
28 changed files with 2579 additions and 0 deletions

47
init_db.py Normal file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/env python3
"""
Database initialization script for Flask 2FA Authentication Application
This script creates the database tables and sets up the initial schema.
"""
import os
import sys
# Add the project root to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from app import create_app, db
from app.models import User
def init_database():
"""Initialize the database with tables."""
app = create_app('development')
with app.app_context():
print("Creating database tables...")
# Create all tables
db.create_all()
print("Database tables created successfully!")
# Show created tables
print("\nCreated tables:")
print("- User table with columns:")
print(" - id (Primary Key)")
print(" - username (Unique)")
print(" - email (Unique)")
print(" - password_hash")
print(" - totp_secret")
print(" - is_2fa_enabled")
print(" - created_at")
print(" - last_login")
print("\nDatabase initialization complete!")
print("You can now run the application with: python run.py")
if __name__ == '__main__':
init_database()