fix import for gradio and streamlit
Browse files7861 unmodified lines78627863786478657866786778687869787078717872787378747875787678777878787978807861 unmodified linesstatus, code = load_project_from_url(url)# Extract space info for deploymentis_valid, username, project_name = check_hf_space_url(url)space_info = f"{username}/{project_name}" if is_valid else ""loaded_history = [[f"Imported Space from {url}", code]]# Determine the correct language/framework based on the imported contentcode_lang = "html" # defaultframework_type = "html" # for language dropdownif is_streamlit_code(code) or is_gradio_code(code):code_lang = "python"framework_type = "python"elif "=== index.html ===" in code and "=== index.js ===" in code and "=== style.css ===" in code:# This is a transformers.js app with the combined formatcode_lang = "html" # Use html for code displayframework_type = "transformers.js" # But set dropdown to transformers.js# Return the updates with proper language settingsreturn [7861 unmodified lines786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907861 unmodified linesstatus, code = load_project_from_url(url)# Extract space info for deploymentis_valid, username, project_name = check_hf_space_url(url)space_name = f"{username}/{project_name}" if is_valid else ""loaded_history = [[f"Imported Space from {url}", code]]# Determine the correct language/framework based on the imported contentcode_lang = "html" # defaultframework_type = "html" # for language dropdown# Check imports to determine framework for Python codeif is_streamlit_code(code):code_lang = "python"framework_type = "python"elif is_gradio_code(code):code_lang = "python"framework_type = "python"elif "=== index.html ===" in code and "=== index.js ===" in code and "=== style.css ===" in code:# This is a transformers.js app with the combined formatcode_lang = "html" # Use html for code displayframework_type = "transformers.js" # But set dropdown to transformers.jselif ("import " in code or "def " in code) and not ("<!DOCTYPE html>" in code or "<html" in code):# This looks like Python code but doesn't match Streamlit/Gradio patterns# Default to Gradio for Python spacescode_lang = "python"framework_type = "gradio"# Return the updates with proper language settingsreturn [
app.py+12-2