Linktodescript / app.py
Doubleupai's picture
Create app.py
e9f8029 verified
import gradio as gr
# Function to generate description from link (dummy implementation)
def generate_description(link):
# In a real-world scenario, you would use this function to process the link
# and generate a description. For this example, we'll just return a dummy description.
if "example.com" in link:
return "This is a description for example.com"
elif "google.com" in link:
return "This is a description for google.com"
else:
return "Description not available for this link."
# Custom CSS for styling
custom_css = """
body {
background-color: #f0f8ff;
font-family: 'Arial', sans-serif;
}
.gradio-container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.gradio-input, .gradio-output {
margin-bottom: 20px;
}
.gradio-input input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.gradio-output textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
resize: none;
}
.gradio-button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.gradio-button:hover {
background-color: #45a049;
}
"""
# Create the Gradio interface with custom CSS
iface = gr.Interface(
fn=generate_description, # Function to call
inputs="text", # Input type: text (for the link)
outputs="text", # Output type: text (for the description)
title="Link to Description",
description="Enter a link to get a description.",
examples=[
["https://www.example.com"],
["https://www.google.com"],
["https://www.github.com"]
],
css=custom_css
)
# Launch the interface
iface.launch()