Day 89 - solution help

I’ve been trying to debug the below but the posts won’t load and replace content from my html file… not sure what’s wrong, but I know it’s in main.py… anyone spot anything? Thanks in advance.

Here’s the repl: https://replit.com/@otto18/Day89100Days#main.py

from flask import Flask, redirect, request
from replit import db

app = Flask(__name__, static_url_path="/static")
 
def getPosts(): 
  entry = ""
  f = open("entry.html", "r")
  entry = f.read()
  f.close()
  keys = db.keys()
  keys = list(keys)
  content = ""
  for key in reversed(keys):
    thisEntry = entry 
    thisEntry = thisEntry.replace("{title}", request.headers["X-Replit-User-Name"])
    thisEntry = thisEntry.replace("{date}", db['date'])
    thisEntry = thisEntry.replace("{post}", db['date']['post'])
    content += thisEntry
  return content

@app.route('/')
def login():
  if request.headers["X-Replit-User-Name"]:
    return redirect("/chat")
  page=""
  f=open("login.html", "r")
  page=f.read()
  f.close()
  return page

@app.route('/chat')
def chat():
  if not request.headers["X-Replit-User-Name"]:
    return redirect("/")
  page=""
  f=open("post.html", "r")
  page+=f.read()
  if len(db.keys()) < 1:
    page = page.replace("{content}","No posts yet. Start the conversation!")
  f.close()
  return page

@app.route('/chat', methods=["POST"])
def post():
  if not request.headers["X-Replit-User-Name"]:
    return redirect("/")
  form = request.form 
  db[form['date']] = {"post":form['post']}
  page=""
  f = open("post.html", "r")
  page = f.read()
  if len(db.keys()) < 1:
    page = page.replace("{content}","No posts yet. Start the conversation!")
  page = page.replace("{content}",getPosts())
  f.close()
  return page

app.run(host='0.0.0.0', port=81)


A post was merged into an existing topic: Day 089 - Project 89 : Community Chat App