Spaces:
Runtime error
Runtime error
File size: 1,127 Bytes
980878b 3ca8c62 980878b 3ca8c62 980878b cf1b677 980878b cf1b677 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import os
def main():
try:
# Ensure the app module is correctly named
app_module = "app"
if not os.path.exists(f"{app_module}.py"):
raise ImportError(f"Module '{app_module}' not found.")
# Ensure there are no syntax errors
with open(f"{app_module}.py", "r") as file:
code = file.read()
compile(code, f"{app_module}.py", 'exec')
# Ensure there are no import errors
import app
# Ensure the app attribute exists in the app module
if not hasattr(app, "app"):
raise AttributeError(f"Attribute 'app' not found in module '{app_module}'.")
print("App module is correctly named, has no syntax errors, no import errors, and contains the 'app' attribute.")
except ImportError as e:
print(f"ImportError: {e}")
except SyntaxError as e:
print(f"SyntaxError: {e}")
except AttributeError as e:
print(f"AttributeError: {e}")
except Exception as e:
print(f"Error: {e}")
# Add an `app` attribute to the module
app = main
if __name__ == "__main__":
main()
|