Rushikesh-Sontakke commited on
Commit
ccc91e5
·
1 Parent(s): 4adc200

show startup traceback in fallback mode

Browse files
Files changed (1) hide show
  1. main.py +9 -3
main.py CHANGED
@@ -17,10 +17,11 @@ try:
17
  app = create_app()
18
 
19
  except Exception as e:
20
- print("✗ Fallback activated due to error:")
21
  import traceback
22
 
23
- traceback.print_exc()
 
 
24
 
25
  from flask import Flask
26
 
@@ -29,7 +30,12 @@ except Exception as e:
29
 
30
  @app.route("/")
31
  def hello():
32
- return "Hello World! (fallback mode)"
 
 
 
 
 
33
 
34
 
35
  @app.route("/healthz")
 
17
  app = create_app()
18
 
19
  except Exception as e:
 
20
  import traceback
21
 
22
+ _err_text = traceback.format_exc()
23
+ print("✗ Fallback activated due to error:")
24
+ print(_err_text)
25
 
26
  from flask import Flask
27
 
 
30
 
31
  @app.route("/")
32
  def hello():
33
+ # Surface the real startup error in the browser to aid debugging.
34
+ return (
35
+ "<h2>Startup failed (fallback mode)</h2><pre>" + _err_text + "</pre>",
36
+ 500,
37
+ {"Content-Type": "text/html; charset=utf-8"},
38
+ )
39
 
40
 
41
  @app.route("/healthz")