ambrosfitz commited on
Commit
d247267
·
verified ·
1 Parent(s): 0d1b0b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -2,12 +2,16 @@ import gradio as gr
2
  from question_generator import generate_microbiology_question
3
  import logging
4
 
 
 
 
5
  current_question = None
6
 
7
  def generate_question():
8
  global current_question
9
  try:
10
  current_question = generate_microbiology_question()
 
11
  return (
12
  current_question['question'],
13
  current_question['options']['A'],
@@ -18,7 +22,7 @@ def generate_question():
18
  "" # Clear any previous error messages
19
  )
20
  except Exception as e:
21
- logging.error(f"Error generating question: {e}")
22
  return ("Error generating question. Please try again.", "", "", "", "", "", str(e))
23
 
24
  def check_answer(choice):
@@ -67,4 +71,5 @@ with gr.Blocks() as demo:
67
  option_e.click(lambda: check_answer("E"), outputs=result)
68
 
69
  if __name__ == "__main__":
 
70
  demo.launch()
 
2
  from question_generator import generate_microbiology_question
3
  import logging
4
 
5
+ # Set up logging
6
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
7
+
8
  current_question = None
9
 
10
  def generate_question():
11
  global current_question
12
  try:
13
  current_question = generate_microbiology_question()
14
+ logging.info("Successfully generated a new question")
15
  return (
16
  current_question['question'],
17
  current_question['options']['A'],
 
22
  "" # Clear any previous error messages
23
  )
24
  except Exception as e:
25
+ logging.error(f"Error generating question: {e}", exc_info=True)
26
  return ("Error generating question. Please try again.", "", "", "", "", "", str(e))
27
 
28
  def check_answer(choice):
 
71
  option_e.click(lambda: check_answer("E"), outputs=result)
72
 
73
  if __name__ == "__main__":
74
+ logging.info("Starting the Microbiology NBME Question Generator app")
75
  demo.launch()