Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from scraper import scrape_site
|
| 3 |
+
from cleaner import clean_data
|
| 4 |
+
|
| 5 |
+
def chatbot(message, history):
|
| 6 |
+
|
| 7 |
+
if message.startswith("scrape"):
|
| 8 |
+
|
| 9 |
+
url = message.replace("scrape ", "")
|
| 10 |
+
|
| 11 |
+
data = scrape_site(url)
|
| 12 |
+
|
| 13 |
+
clean = clean_data(data)
|
| 14 |
+
|
| 15 |
+
return "\n".join(clean[:10])
|
| 16 |
+
|
| 17 |
+
return "Tape: scrape URL"
|
| 18 |
+
|
| 19 |
+
demo = gr.ChatInterface(fn=chatbot)
|
| 20 |
+
|
| 21 |
+
demo.launch()
|