privateuserh commited on
Commit
b817aa2
·
verified ·
1 Parent(s): c2b8f21

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +85 -0
app.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests # To call your backend API
3
+
4
+ # IMPORTANT: Replace with the actual URL of your Cloudflare Worker backend
5
+ BACKEND_API_URL = "YOUR_CLOUDFLARE_WORKER_API_ENDPOINT"
6
+
7
+ def signup_influencer(name, email, social_handle, agree_terms):
8
+ if not agree_terms:
9
+ return "Please accept the terms and conditions."
10
+
11
+ try:
12
+ response = requests.post(f"{BACKEND_API_URL}/signup", json={
13
+ "name": name,
14
+ "email": email,
15
+ "social_handle": social_handle,
16
+ "agreed_terms": agree_terms
17
+ })
18
+ response.raise_for_status() # Raise an exception for HTTP errors
19
+ return "Signup successful! Please check your email for next steps."
20
+ except requests.exceptions.RequestException as e:
21
+ return f"Signup failed: {e}. Please try again."
22
+
23
+ def generate_avatar_content(avatar_type, text_input):
24
+ try:
25
+ # In a real app, you'd send an influencer_id with this request for authentication
26
+ response = requests.post(f"{BACKEND_API_URL}/generate_content", json={
27
+ "avatar_type": avatar_type,
28
+ "text_input": text_input
29
+ })
30
+ response.raise_for_status()
31
+ # Assuming the backend returns a URL to the generated image/video
32
+ generated_url = response.json().get("content_url")
33
+ if generated_url:
34
+ return gr.Image(value=generated_url, label="Generated Content") # Use gr.Image for displaying
35
+ else:
36
+ return gr.Markdown("No content URL received.")
37
+ except requests.exceptions.RequestException as e:
38
+ return gr.Markdown(f"Content generation failed: {e}. Please try again.")
39
+
40
+ with gr.Blocks() as demo:
41
+ gr.Markdown("# SM Plus Influencer Portal")
42
+
43
+ with gr.Tab("Sign Up"):
44
+ gr.Markdown("## Become an SM Plus Influencer")
45
+ name_input = gr.Textbox(label="Your Name")
46
+ email_input = gr.Textbox(label="Your Email")
47
+ social_input = gr.Textbox(label="Main Social Media Handle")
48
+
49
+ gr.Markdown("### Media Carriage and AI Avatar Usage Agreement")
50
+ # Provide a link to your full agreement document or page
51
+ gr.Markdown("Please read the [full agreement here](link_to_your_agreement_pdf_or_page).")
52
+ agree_checkbox = gr.Checkbox(label="I agree to the Media Carriage and AI Avatar Usage Agreement.")
53
+
54
+ signup_button = gr.Button("Sign Up")
55
+ signup_output = gr.Markdown()
56
+ signup_button.click(
57
+ signup_influencer,
58
+ inputs=[name_input, email_input, social_input, agree_checkbox],
59
+ outputs=signup_output
60
+ )
61
+
62
+ with gr.Tab("AI Avatar Generator"):
63
+ gr.Markdown("## Generate Content with AI Avatars")
64
+ # The AI agent types listed here should align with your agreement
65
+ avatar_selection = gr.Dropdown(
66
+ [
67
+ "Convention Series Cosplay",
68
+ "Feature Length Cosplay (B-Roll)",
69
+ "Bitroll Content Module (Generic)", # Adjust as per your specific modules
70
+ "Nano AI Avatars / Level 1 Ad Copy",
71
+ "AB1836 CA Module"
72
+ ],
73
+ label="Select AI Avatar/Module Type"
74
+ )
75
+ text_input_for_ai = gr.Textbox(label="Enter your content script/ad copy")
76
+ generate_button = gr.Button("Generate AI Content")
77
+ generated_content_output = gr.Image(label="Generated Content", visible=True) # Or gr.Video if generating video
78
+
79
+ generate_button.click(
80
+ generate_avatar_content,
81
+ inputs=[avatar_selection, text_input_for_ai],
82
+ outputs=generated_content_output
83
+ )
84
+
85
+ demo.launch()