Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -994,6 +994,7 @@ def process_excel_to_word(excel_file_path):
|
|
| 994 |
# ======================== GRADIO INTERFACE ========================
|
| 995 |
def create_interface():
|
| 996 |
generator = BlogGenerator()
|
|
|
|
| 997 |
with gr.Blocks(title="π― Digiworks Unified Blog Generator", theme=gr.themes.Soft()) as interface:
|
| 998 |
gr.HTML("""<div style='text-align: center; padding: 25px; background: linear-gradient(135deg, #1a365d 0%, #2d3748 100%); color: white; margin-bottom: 25px; border-radius: 15px;'><h1 style='margin: 0; font-size: 2.5em; font-weight: 900;'>π― Digiworks Unified Blog Generator</h1><p style='margin: 15px 0 0 0; font-size: 1.2em;'>Idea Generation β Blog Post Creation β Word Document Formatting</p></div>""")
|
| 999 |
with gr.Tab("π‘ Idea Generation"):
|
|
@@ -1048,7 +1049,7 @@ def create_interface():
|
|
| 1048 |
gr.HTML("""<div style='background: #065f46; color: white; padding: 15px; border-radius: 8px; text-align: center; margin-left: 15px; border: 1px solid #10b981;'><strong style='color: #6ee7b7;'>π‘ WordPress Tip:</strong><span style='color: white;'>Copy sections directly from Word to WordPress editor!</span></div>""")
|
| 1049 |
gr.HTML("""<div style='text-align: center; padding: 20px; margin-top: 25px; border-top: 1px solid #e0e0e0;'><p style='color: #666; margin: 0;'>π― <strong>Digiworks Unified Blog Generator</strong> | Idea Generation β Blog Post Creation β Word Document Formatting<br><small>Perfect for content teams and marketers</small></p></div>""")
|
| 1050 |
|
| 1051 |
-
# --- HANDLER FUNCTIONS
|
| 1052 |
def toggle_content_type(mode): return gr.update(visible=(mode == "Single Type"))
|
| 1053 |
def handle_idea_generation(mode, content_type_val, num_topics_val):
|
| 1054 |
try:
|
|
@@ -1173,7 +1174,7 @@ def create_interface():
|
|
| 1173 |
generate_posts_btn.click(fn=generate_selected_posts, inputs=[excel_upload, topics_checklist, loaded_data], outputs=[posts_status, posts_dataframe, download_posts_btn])
|
| 1174 |
word_excel_input.change(fn=process_excel_file, inputs=[word_excel_input], outputs=[word_status, word_preview, download_word_btn])
|
| 1175 |
generate_word_btn.click(fn=generate_word_document, inputs=[word_excel_input], outputs=[word_status, word_preview, download_word_btn])
|
| 1176 |
-
|
| 1177 |
return interface
|
| 1178 |
|
| 1179 |
|
|
@@ -1190,7 +1191,6 @@ if __name__ == "__main__":
|
|
| 1190 |
print("="*70)
|
| 1191 |
|
| 1192 |
interface = create_interface()
|
| 1193 |
-
interface.launch(share=True, debug=True)
|
| 1194 |
|
| 1195 |
# MODIFIED: Get Gradio credentials from Hugging Face Secrets
|
| 1196 |
gradio_user = os.environ.get("GRADIO_USERNAME")
|
|
@@ -1202,7 +1202,8 @@ if __name__ == "__main__":
|
|
| 1202 |
|
| 1203 |
print("β
Gradio authentication enabled.")
|
| 1204 |
|
| 1205 |
-
#
|
|
|
|
| 1206 |
interface.launch(auth=(gradio_user, gradio_pass))
|
| 1207 |
|
| 1208 |
print("β
Unified blog generator launched!")
|
|
|
|
| 994 |
# ======================== GRADIO INTERFACE ========================
|
| 995 |
def create_interface():
|
| 996 |
generator = BlogGenerator()
|
| 997 |
+
# MODIFIED: All event handlers and listeners are now correctly indented inside this "with" block.
|
| 998 |
with gr.Blocks(title="π― Digiworks Unified Blog Generator", theme=gr.themes.Soft()) as interface:
|
| 999 |
gr.HTML("""<div style='text-align: center; padding: 25px; background: linear-gradient(135deg, #1a365d 0%, #2d3748 100%); color: white; margin-bottom: 25px; border-radius: 15px;'><h1 style='margin: 0; font-size: 2.5em; font-weight: 900;'>π― Digiworks Unified Blog Generator</h1><p style='margin: 15px 0 0 0; font-size: 1.2em;'>Idea Generation β Blog Post Creation β Word Document Formatting</p></div>""")
|
| 1000 |
with gr.Tab("π‘ Idea Generation"):
|
|
|
|
| 1049 |
gr.HTML("""<div style='background: #065f46; color: white; padding: 15px; border-radius: 8px; text-align: center; margin-left: 15px; border: 1px solid #10b981;'><strong style='color: #6ee7b7;'>π‘ WordPress Tip:</strong><span style='color: white;'>Copy sections directly from Word to WordPress editor!</span></div>""")
|
| 1050 |
gr.HTML("""<div style='text-align: center; padding: 20px; margin-top: 25px; border-top: 1px solid #e0e0e0;'><p style='color: #666; margin: 0;'>π― <strong>Digiworks Unified Blog Generator</strong> | Idea Generation β Blog Post Creation β Word Document Formatting<br><small>Perfect for content teams and marketers</small></p></div>""")
|
| 1051 |
|
| 1052 |
+
# --- HANDLER FUNCTIONS ---
|
| 1053 |
def toggle_content_type(mode): return gr.update(visible=(mode == "Single Type"))
|
| 1054 |
def handle_idea_generation(mode, content_type_val, num_topics_val):
|
| 1055 |
try:
|
|
|
|
| 1174 |
generate_posts_btn.click(fn=generate_selected_posts, inputs=[excel_upload, topics_checklist, loaded_data], outputs=[posts_status, posts_dataframe, download_posts_btn])
|
| 1175 |
word_excel_input.change(fn=process_excel_file, inputs=[word_excel_input], outputs=[word_status, word_preview, download_word_btn])
|
| 1176 |
generate_word_btn.click(fn=generate_word_document, inputs=[word_excel_input], outputs=[word_status, word_preview, download_word_btn])
|
| 1177 |
+
|
| 1178 |
return interface
|
| 1179 |
|
| 1180 |
|
|
|
|
| 1191 |
print("="*70)
|
| 1192 |
|
| 1193 |
interface = create_interface()
|
|
|
|
| 1194 |
|
| 1195 |
# MODIFIED: Get Gradio credentials from Hugging Face Secrets
|
| 1196 |
gradio_user = os.environ.get("GRADIO_USERNAME")
|
|
|
|
| 1202 |
|
| 1203 |
print("β
Gradio authentication enabled.")
|
| 1204 |
|
| 1205 |
+
# MODIFIED: Only one .launch() call is made, using the credentials from the secrets.
|
| 1206 |
+
# Removed share=True and debug=True as they are not needed on Spaces.
|
| 1207 |
interface.launch(auth=(gradio_user, gradio_pass))
|
| 1208 |
|
| 1209 |
print("β
Unified blog generator launched!")
|