Spaces:
Paused
Paused
Update app.py
Browse files33 unmodified lines3435363738394041222 unmodified lines26426526626726826927027127227327427527627727827928028128241 unmodified lines32432532632732832933033133233333433541 unmodified lines37737837938038138238338438538633 unmodified lines# Debug: Print raw response to see structureprint(f"Raw API Response: {json.dumps(res_json, indent=2)}")# NEW: Parse the actual response structure# The response has "credits" array and "total_remaining_credits"total_remaining_credits = res_json.get('total_remaining_credits', 0)credits_list = res_json.get('credits', [])222 unmodified lineselse:return "🚀 **Plenty of credits!** Ready for extensive image generation work and experimentation."# Create Gradio interface with custom themetheme = gr.themes.Soft(primary_hue="purple",secondary_hue="indigo",font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"]).set(button_primary_background_fill="linear-gradient(135deg, #667eea 0%, #764ba2 100%)",button_primary_background_fill_hover="linear-gradient(135deg, #764ba2 0%, #667eea 100%)",button_primary_text_color="white",button_primary_border_color="rgba(255,255,255,0.2)",)with gr.Blocks(theme=theme, title="StableCog Credit Monitor", css="footer {display: none !important;}") as demo:gr.Markdown("""# 🎯 StableCog Credit Dashboard41 unmodified linescheck_btn = gr.Button("🔄 Check Credits Now",variant="primary",size="lg",elem_classes="refresh-btn")# Auto-check on loaddemo.load(fn=update_display, inputs=None, outputs=[html_output, raw_output, credits_display, usage_display])# Connect button and update recommendationdef update_all():41 unmodified lines""")if __name__ == "__main__":# For Hugging Face Spacesdemo.launch(server_name="0.0.0.0",server_port=7860,share=False,show_error=True)33 unmodified lines34353637383940222 unmodified lines26326426526626726826927027127227327427527627727827928028128228328428541 unmodified lines32732832933033133233333433533633733833934034134234334434534634734834935035135235341 unmodified lines39539639739839940040140240340440533 unmodified lines# Debug: Print raw response to see structureprint(f"Raw API Response: {json.dumps(res_json, indent=2)}")# Parse the actual response structuretotal_remaining_credits = res_json.get('total_remaining_credits', 0)credits_list = res_json.get('credits', [])222 unmodified lineselse:return "🚀 **Plenty of credits!** Ready for extensive image generation work and experimentation."# Create Gradio interface with Gradio 5 themetheme = gr.themes.Soft(primary_hue="purple",secondary_hue="indigo",font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"])with gr.Blocks(theme=theme,title="StableCog Credit Monitor",css="""footer {display: none !important;}.gradio-container {max-width: 1200px !important;}.stat-box input {font-weight: bold !important; font-size: 18px !important;}.recommendation-box textarea {font-size: 16px !important; line-height: 1.5 !important;}""") as demo:gr.Markdown("""# 🎯 StableCog Credit Dashboard41 unmodified linescheck_btn = gr.Button("🔄 Check Credits Now",variant="primary",scale=1,size="lg")gr.Button("📖 View Documentation",variant="secondary",scale=0,size="lg",link="https://stablecog.com/docs/api")# Auto-check on loaddemo.load(fn=update_display,inputs=None,outputs=[html_output, raw_output, credits_display, usage_display]).then(fn=get_recommendation,inputs=[credits_display, usage_display],outputs=recommendation_box)# Connect button and update recommendationdef update_all():41 unmodified lines""")if __name__ == "__main__":# For Hugging Face Spaces - Gradio 5 syntaxdemo.launch(server_name="0.0.0.0",server_port=7860,share=False,show_error=True,debug=False)
app.py+32-13