Spaces:
Build error
Build error
Update app.py
Browse files993 unmodified lines99499599699799899948 unmodified lines1048104910501051105210531054118 unmodified lines117311741175117611771178117910 unmodified lines11901191119211931194119511965 unmodified lines1202120312041205120612071208993 unmodified lines# ======================== GRADIO INTERFACE ========================def create_interface():generator = BlogGenerator()with gr.Blocks(title="π― Digiworks Unified Blog Generator", theme=gr.themes.Soft()) as interface: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>""")with gr.Tab("π‘ Idea Generation"):48 unmodified linesgr.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>""")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>""")# --- HANDLER FUNCTIONS (MODIFIED for Incremental Save) ---def toggle_content_type(mode): return gr.update(visible=(mode == "Single Type"))def handle_idea_generation(mode, content_type_val, num_topics_val):try:118 unmodified linesgenerate_posts_btn.click(fn=generate_selected_posts, inputs=[excel_upload, topics_checklist, loaded_data], outputs=[posts_status, posts_dataframe, download_posts_btn])word_excel_input.change(fn=process_excel_file, inputs=[word_excel_input], outputs=[word_status, word_preview, download_word_btn])generate_word_btn.click(fn=generate_word_document, inputs=[word_excel_input], outputs=[word_status, word_preview, download_word_btn])return interface10 unmodified linesprint("="*70)interface = create_interface()interface.launch(share=True, debug=True)# MODIFIED: Get Gradio credentials from Hugging Face Secretsgradio_user = os.environ.get("GRADIO_USERNAME")5 unmodified linesprint("β Gradio authentication enabled.")# Launch the interface with credentials from the secretsinterface.launch(auth=(gradio_user, gradio_pass))print("β Unified blog generator launched!")993 unmodified lines994995996997998999100048 unmodified lines1049105010511052105310541055118 unmodified lines117411751176117711781179118010 unmodified lines1191119211931194119511965 unmodified lines12021203120412051206120712081209993 unmodified lines# ======================== GRADIO INTERFACE ========================def create_interface():generator = BlogGenerator()# MODIFIED: All event handlers and listeners are now correctly indented inside this "with" block.with gr.Blocks(title="π― Digiworks Unified Blog Generator", theme=gr.themes.Soft()) as interface: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>""")with gr.Tab("π‘ Idea Generation"):48 unmodified linesgr.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>""")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>""")# --- HANDLER FUNCTIONS ---def toggle_content_type(mode): return gr.update(visible=(mode == "Single Type"))def handle_idea_generation(mode, content_type_val, num_topics_val):try:118 unmodified linesgenerate_posts_btn.click(fn=generate_selected_posts, inputs=[excel_upload, topics_checklist, loaded_data], outputs=[posts_status, posts_dataframe, download_posts_btn])word_excel_input.change(fn=process_excel_file, inputs=[word_excel_input], outputs=[word_status, word_preview, download_word_btn])generate_word_btn.click(fn=generate_word_document, inputs=[word_excel_input], outputs=[word_status, word_preview, download_word_btn])return interface10 unmodified linesprint("="*70)interface = create_interface()# MODIFIED: Get Gradio credentials from Hugging Face Secretsgradio_user = os.environ.get("GRADIO_USERNAME")5 unmodified linesprint("β Gradio authentication enabled.")# MODIFIED: Only one .launch() call is made, using the credentials from the secrets.# Removed share=True and debug=True as they are not needed on Spaces.interface.launch(auth=(gradio_user, gradio_pass))print("β Unified blog generator launched!")
app.py+5-4