|
import os |
|
import sys |
|
import shutil |
|
import stat |
|
|
|
|
|
def clear_pycache(): |
|
print("DEBUG: Clearing Python cache...") |
|
for root, dirs, files in os.walk("."): |
|
for dir_name in dirs: |
|
if dir_name == "__pycache__": |
|
pycache_path = os.path.join(root, dir_name) |
|
print(f"DEBUG: Removing {pycache_path}") |
|
shutil.rmtree(pycache_path) |
|
|
|
|
|
def verify_permissions(file_path): |
|
if os.path.exists(file_path): |
|
|
|
if not os.access(file_path, os.R_OK): |
|
print(f"DEBUG: Fixing permissions for {file_path}") |
|
os.chmod(file_path, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH) |
|
|
|
|
|
clear_pycache() |
|
verify_permissions("routes/auth.py") |
|
verify_permissions("routes/menu.py") |
|
verify_permissions("routes/orders.py") |
|
verify_permissions("utils/file_initializer.py") |
|
|
|
|
|
current_dir = os.path.dirname(os.path.abspath(__file__)) |
|
if current_dir not in sys.path: |
|
sys.path.insert(0, current_dir) |
|
|
|
|
|
print("DEBUG: sys.path =", sys.path) |
|
routes_dir = os.path.join(current_dir, "routes") |
|
auth_file_path = os.path.join(routes_dir, "auth.py") |
|
print("DEBUG: Does 'routes' directory exist? ", os.path.exists(routes_dir)) |
|
print("DEBUG: Does 'auth.py' exist in 'routes'? ", os.path.exists(auth_file_path)) |
|
|
|
|
|
try: |
|
from routes.auth import login, sign_up |
|
from routes.menu import load_menu |
|
from routes.orders import add_to_order, view_order, place_order |
|
from utils.file_initializer import initialize_files |
|
except ModuleNotFoundError as e: |
|
print(f"ERROR: {e}") |
|
print("DEBUG: ModuleNotFoundError occurred. Check the paths and file structure.") |
|
sys.exit(1) |
|
|
|
|
|
initialize_files() |
|
|
|
def restaurant_interface(): |
|
from gradio import Blocks |
|
with Blocks() as app: |
|
app.load_page("templates/index.html") |
|
return app |
|
|
|
if __name__ == "__main__": |
|
app = restaurant_interface() |
|
app.launch() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
000000000ppppoooppoopoopp |
|
|