openfree commited on
Commit
3a7668f
·
verified ·
1 Parent(s): d8245c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -12,6 +12,20 @@ def main():
12
  st.error("⚠️ The application code wasn't found in secrets. Please add the MAIN_CODE secret.")
13
  return
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Create a temporary Python file
16
  with NamedTemporaryFile(suffix='.py', delete=False, mode='w') as tmp:
17
  tmp.write(code)
 
12
  st.error("⚠️ The application code wasn't found in secrets. Please add the MAIN_CODE secret.")
13
  return
14
 
15
+ # Try to fix any potential string issues
16
+ try:
17
+ # Just to verify the code is syntactically valid before writing to file
18
+ compile(code, '<string>', 'exec')
19
+ except SyntaxError as e:
20
+ st.error(f"⚠️ Syntax error in the application code: {str(e)}")
21
+ st.info("Please check your code for unterminated strings or other syntax errors.")
22
+
23
+ # Show the problematic line if possible
24
+ if hasattr(e, 'lineno') and hasattr(e, 'text'):
25
+ st.code(f"Line {e.lineno}: {e.text}")
26
+ st.write(f"Error occurs near character position: {e.offset}")
27
+ return
28
+
29
  # Create a temporary Python file
30
  with NamedTemporaryFile(suffix='.py', delete=False, mode='w') as tmp:
31
  tmp.write(code)