when i make a room it wont appear fix this from flask import Flask, render_template, request, redirect, url_for, flash, session
from flask_socketio import SocketIO, emit
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
from werkzeug.security import generate_password_hash, check_password_hash
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SECRET_KEY'] = 'TXUypiNoVmMCNl4TyoRgijzCxkyq4ZAu'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///chat_app.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
socketio = SocketIO(app)

# Initialize login manager
login_manager = LoginManager()
login_manager.init_app(app)

# Initialize the database
db = SQLAlchemy(app)

# User model
class User(UserMixin, db.Model):
    id = db.Column(db.String(150), primary_key=True)
    username = db.Column(db.String(150), unique=True, nullable=False)
    password = db.Column(db.String(150), nullable=False)

# Chat room model
class ChatRoom(db.Model):
    id = db.Column(db.String(150), primary_key=True)
    password = db.Column(db.String(150), nullable=True)
    creator = db.Column(db.String(150), nullable=False)

@login_manager.user_loader
def load_user(user_id):
    return User.query.get(user_id)

@app.route('/')
def index():
    rooms = ChatRoom.query.all()
    return render_template('index.html', rooms=rooms, current_user=current_user)

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        user = User.query.filter_by(username=username).first()
        
        if user and check_password_hash(user.password, password):
            login_user(user)
            return redirect(url_for('index'))
        else:
            flash('Invalid username or password!', 'error')
    
    return render_template('login.html')

@app.route('/create_room', methods=['POST'])
@login_required
def create_room():
    room_name = request.form['room_name']
    password = request.form.get('password', '')
    creator = current_user.username
    new_room = ChatRoom(id=room_name, password=password, creator=creator)
    db.session.add(new_room)
    db.session.commit()
    flash('Chat room created successfully!', 'success')
    return redirect(url_for('index'))

@app.route('/join_room/<room_name>', methods=['GET', 'POST'])
def join_room(room_name):
    room = ChatRoom.query.get(room_name)
    if room:
        if request.method == 'POST':
            password = request.form['password']
            if room.password == password:
                session['creator'] = room.creator
                return render_template('chat.html', room_name=room_name, creator=session['creator'])
            else:
                flash("Incorrect password!", 'error')
                return redirect(url_for('join_room', room_name=room_name))
        return render_template('join.html', room_name=room_name, room=room)
    else:
        flash('Room not found!', 'error')
        return redirect(url_for('index'))

@app.route('/delete_room/<room_name>', methods=['POST'])
@login_required
def delete_room(room_name):
    room = ChatRoom.query.get(room_name)
    if room:
        if current_user.username == room.creator:
            db.session.delete(room)
            db.session.commit()
            flash('Room deleted successfully!', 'success')
        else:
            flash('You are not authorized to delete this room!', 'error')
    else:
        flash('Room not found!', 'error')
    return redirect(url_for('index'))

@app.route('/logout')
@login_required
def logout():
    logout_user()
    flash('You have been logged out.', 'success')
    return redirect(url_for('index'))

@app.route('/register', methods=['GET', 'POST'])
def register():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        if User.query.filter_by(username=username).first():
            flash('Username already exists!', 'error')
        else:
            new_user = User(id=username, username=username, password=generate_password_hash(password))
            db.session.add(new_user)
            db.session.commit()
            flash('Registration successful! You can now log in.', 'success')
            return redirect(url_for('login'))
    return render_template('register.html')

if __name__ == '__main__':
    with app.app_context():
        db.create_all()
    app.run(host='0.0.0.0', port=5000, debug=True)