sailajaai commited on
Commit
7cbf443
·
verified ·
1 Parent(s): d30fa43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -47,8 +47,10 @@ from services.evaluation import evaluate_answer # Imported, models loaded here
47
 
48
  @app.route("/")
49
  def home():
50
- # This line should now work as mongo.db is correctly initialized to assessment_db
51
- tests = list(mongo.db.tests.find({}, {"_id": 0}))
 
 
52
  return render_template("home.html", tests=tests)
53
 
54
  if __name__ == "__main__":
 
47
 
48
  @app.route("/")
49
  def home():
50
+ # This line uses the explicit client connection (mongo.cx) and database name (DB_NAME)
51
+ # to avoid the 'AttributeError: NoneType' object has no attribute 'tests' crash.
52
+ global DB_NAME
53
+ tests = list(mongo.cx[DB_NAME].tests.find({}, {"_id": 0}))
54
  return render_template("home.html", tests=tests)
55
 
56
  if __name__ == "__main__":