Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# ==============================================
|
| 2 |
# SCREENSHOT SCRAPER FOR N8N
|
| 3 |
-
# Complete version with all improvements
|
| 4 |
# ==============================================
|
| 5 |
|
| 6 |
import gradio as gr
|
|
@@ -676,7 +676,7 @@ async def api_scrape(data: dict = None, url: str = None):
|
|
| 676 |
}
|
| 677 |
|
| 678 |
# ==============================================
|
| 679 |
-
# GRADIO INTERFACE
|
| 680 |
# ==============================================
|
| 681 |
|
| 682 |
def gradio_scrape(url: str, use_html_fallback: bool = False):
|
|
@@ -718,7 +718,7 @@ def gradio_scrape(url: str, use_html_fallback: bool = False):
|
|
| 718 |
error_msg = f"## ❌ Unexpected Error\n\n{str(e)}"
|
| 719 |
return error_msg, {"error": str(e), "url": url}
|
| 720 |
|
| 721 |
-
# Create Gradio interface
|
| 722 |
iface = gr.Interface(
|
| 723 |
fn=gradio_scrape,
|
| 724 |
inputs=[
|
|
@@ -754,12 +754,20 @@ iface = gr.Interface(
|
|
| 754 |
["https://news.ycombinator.com"],
|
| 755 |
["https://httpbin.org/html"]
|
| 756 |
],
|
| 757 |
-
theme="soft"
|
| 758 |
-
allow_flagging
|
| 759 |
)
|
| 760 |
|
| 761 |
-
#
|
| 762 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 763 |
|
| 764 |
# ==============================================
|
| 765 |
# APPLICATION STARTUP
|
|
@@ -774,6 +782,9 @@ if __name__ == "__main__":
|
|
| 774 |
print(f"🔧 Default OCR Model: {Config.DEFAULT_MODEL}")
|
| 775 |
print("="*60 + "\n")
|
| 776 |
|
|
|
|
|
|
|
|
|
|
| 777 |
uvicorn.run(
|
| 778 |
app,
|
| 779 |
host="0.0.0.0",
|
|
|
|
| 1 |
# ==============================================
|
| 2 |
# SCREENSHOT SCRAPER FOR N8N
|
| 3 |
+
# Complete version with all improvements - GRADIO 4.x COMPATIBLE
|
| 4 |
# ==============================================
|
| 5 |
|
| 6 |
import gradio as gr
|
|
|
|
| 676 |
}
|
| 677 |
|
| 678 |
# ==============================================
|
| 679 |
+
# GRADIO INTERFACE (UPDATED FOR GRADIO 4.x)
|
| 680 |
# ==============================================
|
| 681 |
|
| 682 |
def gradio_scrape(url: str, use_html_fallback: bool = False):
|
|
|
|
| 718 |
error_msg = f"## ❌ Unexpected Error\n\n{str(e)}"
|
| 719 |
return error_msg, {"error": str(e), "url": url}
|
| 720 |
|
| 721 |
+
# Create Gradio interface with Gradio 4.x compatible settings
|
| 722 |
iface = gr.Interface(
|
| 723 |
fn=gradio_scrape,
|
| 724 |
inputs=[
|
|
|
|
| 754 |
["https://news.ycombinator.com"],
|
| 755 |
["https://httpbin.org/html"]
|
| 756 |
],
|
| 757 |
+
theme="soft"
|
| 758 |
+
# Removed allow_flagging parameter for Gradio 4.x compatibility
|
| 759 |
)
|
| 760 |
|
| 761 |
+
# ==============================================
|
| 762 |
+
# GRADIO LAUNCH CONFIGURATION
|
| 763 |
+
# ==============================================
|
| 764 |
+
|
| 765 |
+
def launch_gradio():
|
| 766 |
+
"""Launch Gradio interface"""
|
| 767 |
+
# Mount Gradio app to FastAPI
|
| 768 |
+
app = gr.mount_gradio_app(app, iface, path="/")
|
| 769 |
+
|
| 770 |
+
return app
|
| 771 |
|
| 772 |
# ==============================================
|
| 773 |
# APPLICATION STARTUP
|
|
|
|
| 782 |
print(f"🔧 Default OCR Model: {Config.DEFAULT_MODEL}")
|
| 783 |
print("="*60 + "\n")
|
| 784 |
|
| 785 |
+
# Configure Gradio launch
|
| 786 |
+
app = launch_gradio()
|
| 787 |
+
|
| 788 |
uvicorn.run(
|
| 789 |
app,
|
| 790 |
host="0.0.0.0",
|