Update app.py
Browse files
app.py
CHANGED
|
@@ -5,15 +5,167 @@ def generate(topic, platform):
|
|
| 5 |
post, engagement, tone, clarity = workflow(topic, platform)
|
| 6 |
return post, engagement, tone, clarity
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
generate_btn.click(fn=generate, inputs=[topic_input, platform_input], outputs=[post_output, engagement_output, tone_output, clarity_output])
|
| 19 |
|
|
|
|
| 5 |
post, engagement, tone, clarity = workflow(topic, platform)
|
| 6 |
return post, engagement, tone, clarity
|
| 7 |
|
| 8 |
+
css = """
|
| 9 |
+
/* Gradient background */
|
| 10 |
+
body {
|
| 11 |
+
margin: 0;
|
| 12 |
+
padding: 0;
|
| 13 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 14 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 15 |
+
color: #2d3748;
|
| 16 |
+
min-height: 100vh;
|
| 17 |
+
display: flex;
|
| 18 |
+
justify-content: center;
|
| 19 |
+
align-items: center;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/* Glassmorphism container */
|
| 23 |
+
.gradio-container {
|
| 24 |
+
background: rgba(255, 255, 255, 0.15);
|
| 25 |
+
border-radius: 20px;
|
| 26 |
+
backdrop-filter: blur(12px);
|
| 27 |
+
-webkit-backdrop-filter: blur(12px);
|
| 28 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
| 29 |
+
padding: 3rem 3.5rem;
|
| 30 |
+
width: 95%;
|
| 31 |
+
max-width: 960px;
|
| 32 |
+
color: #1a202c;
|
| 33 |
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/* Title with underline */
|
| 37 |
+
#title {
|
| 38 |
+
font-size: 3rem;
|
| 39 |
+
font-weight: 900;
|
| 40 |
+
text-align: center;
|
| 41 |
+
color: #fff;
|
| 42 |
+
letter-spacing: 1.4px;
|
| 43 |
+
margin-bottom: 0.3rem;
|
| 44 |
+
text-shadow: 0 2px 6px rgba(0,0,0,0.25);
|
| 45 |
+
position: relative;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
#title::after {
|
| 49 |
+
content: "";
|
| 50 |
+
display: block;
|
| 51 |
+
width: 80px;
|
| 52 |
+
height: 3px;
|
| 53 |
+
background: #f6ad55;
|
| 54 |
+
margin: 12px auto 0;
|
| 55 |
+
border-radius: 2px;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/* Subtitle style */
|
| 59 |
+
#subtitle {
|
| 60 |
+
font-size: 1.2rem;
|
| 61 |
+
font-weight: 600;
|
| 62 |
+
color: #e2e8f0dd;
|
| 63 |
+
text-align: center;
|
| 64 |
+
margin-bottom: 2.5rem;
|
| 65 |
+
font-style: italic;
|
| 66 |
+
text-shadow: 0 1px 3px rgba(0,0,0,0.15);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/* Labels */
|
| 70 |
+
.input-label, .output-label {
|
| 71 |
+
font-weight: 700;
|
| 72 |
+
font-size: 1rem;
|
| 73 |
+
margin-bottom: 0.5rem;
|
| 74 |
+
color: #e2e8f0dd;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/* Input styling with icon placeholder */
|
| 78 |
+
input[type="text"], textarea {
|
| 79 |
+
width: 100%;
|
| 80 |
+
padding: 14px 18px;
|
| 81 |
+
font-size: 1rem;
|
| 82 |
+
border: none;
|
| 83 |
+
border-radius: 12px;
|
| 84 |
+
background: rgba(255, 255, 255, 0.85);
|
| 85 |
+
box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
|
| 86 |
+
transition: box-shadow 0.3s ease, background 0.3s ease;
|
| 87 |
+
color: #2d3748;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
input[type="text"]:focus, textarea:focus {
|
| 91 |
+
outline: none;
|
| 92 |
+
background: #fff;
|
| 93 |
+
box-shadow: 0 0 12px 2px #f6ad55;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/* Readonly output styling */
|
| 97 |
+
textarea[readonly], input[readonly] {
|
| 98 |
+
background: rgba(255, 255, 255, 0.7);
|
| 99 |
+
color: #2d3748;
|
| 100 |
+
resize: vertical;
|
| 101 |
+
box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/* Button styling with animation */
|
| 105 |
+
.gr-button {
|
| 106 |
+
width: 100%;
|
| 107 |
+
padding: 16px 0;
|
| 108 |
+
background: linear-gradient(45deg, #f6ad55, #d69e2e);
|
| 109 |
+
border: none;
|
| 110 |
+
border-radius: 14px;
|
| 111 |
+
color: #fff;
|
| 112 |
+
font-weight: 700;
|
| 113 |
+
font-size: 1.2rem;
|
| 114 |
+
cursor: pointer;
|
| 115 |
+
box-shadow: 0 8px 15px rgba(246,173,85,0.4);
|
| 116 |
+
transition: box-shadow 0.3s ease, transform 0.3s ease;
|
| 117 |
+
margin-top: 2rem;
|
| 118 |
+
letter-spacing: 0.05em;
|
| 119 |
+
text-transform: uppercase;
|
| 120 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.gr-button:hover {
|
| 124 |
+
box-shadow: 0 12px 20px rgba(246,173,85,0.65);
|
| 125 |
+
transform: translateY(-3px);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/* Layout for rows and columns */
|
| 129 |
+
.gr-row {
|
| 130 |
+
gap: 2.5rem;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/* Output boxes spacing */
|
| 134 |
+
.gr-row > .gradio-textbox {
|
| 135 |
+
margin-top: 1.3rem;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
/* Responsive adjustments */
|
| 139 |
+
@media (max-width: 768px) {
|
| 140 |
+
.gradio-container {
|
| 141 |
+
padding: 2rem 2rem;
|
| 142 |
+
}
|
| 143 |
+
.gr-row {
|
| 144 |
+
flex-direction: column;
|
| 145 |
+
gap: 2rem;
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
"""
|
| 149 |
+
|
| 150 |
+
with gr.Blocks(css=css) as demo:
|
| 151 |
+
gr.Markdown(
|
| 152 |
+
"""
|
| 153 |
+
<div id="title">Social Media Post Generator</div>
|
| 154 |
+
<div id="subtitle">Craft professional, clear, and engaging posts tailored to your platform.</div>
|
| 155 |
+
"""
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
with gr.Row():
|
| 159 |
+
with gr.Column(scale=1):
|
| 160 |
+
topic_input = gr.Textbox(label="Topic", placeholder="Enter your topic here")
|
| 161 |
+
platform_input = gr.Textbox(label="Platform", placeholder="E.g., LinkedIn, Twitter")
|
| 162 |
+
generate_btn = gr.Button("Generate Post")
|
| 163 |
+
|
| 164 |
+
with gr.Column(scale=1):
|
| 165 |
+
post_output = gr.Textbox(label="Generated Post", lines=8, interactive=False)
|
| 166 |
+
engagement_output = gr.Textbox(label="Engagement Score", interactive=False)
|
| 167 |
+
tone_output = gr.Textbox(label="Tone Score", interactive=False)
|
| 168 |
+
clarity_output = gr.Textbox(label="Clarity Score", interactive=False)
|
| 169 |
|
| 170 |
generate_btn.click(fn=generate, inputs=[topic_input, platform_input], outputs=[post_output, engagement_output, tone_output, clarity_output])
|
| 171 |
|