Offex commited on
Commit
8ca08e6
·
verified ·
1 Parent(s): fd666b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -67
app.py CHANGED
@@ -1,74 +1,25 @@
1
  import gradio as gr
2
  import requests
3
- import random
4
- import string
5
 
6
- API_URL = "https://api.mail.tm"
7
 
8
- def get_domain():
9
- res = requests.get(f"{API_URL}/domains")
10
- return res.json()['hydra:member'][0]['domain']
11
-
12
- def create_mail():
13
- try:
14
- domain = get_domain()
15
- # रैंडम यूजरनाम और पासवर्ड बनाना
16
- user = ''.join(random.choices(string.ascii_lowercase + string.digits, k=10))
17
- password = "Password123!"
18
- email = f"{user}@{domain}"
19
-
20
- payload = {"address": email, "password": password}
21
- res = requests.post(f"{API_URL}/accounts", json=payload)
22
-
23
- if res.status_code == 201:
24
- # टोकन लेना (Login करना)
25
- token_res = requests.post(f"{API_URL}/token", json=payload)
26
- token = token_res.json()['token']
27
- return email, token
28
- else:
29
- return "Error: Account not created", ""
30
- except Exception as e:
31
- return f"Error: {str(e)}", ""
32
-
33
- def check_inbox(token):
34
- if not token:
35
- return "पहले ईमेल जनरेट करें!"
36
-
37
- headers = {"Authorization": f"Bearer {token}"}
38
- try:
39
- res = requests.get(f"{API_URL}/messages", headers=headers)
40
- messages = res.json()['hydra:member']
41
-
42
- if not messages:
43
- return "इनबॉक्स खाली है। (Refresh करें)"
44
-
45
- output = ""
46
- for msg in messages:
47
- msg_id = msg['id']
48
- # पूरा मैसेज पढ़ना
49
- detail = requests.get(f"{API_URL}/messages/{msg_id}", headers=headers).json()
50
- output += f"From: {detail['from']['address']}\nSubject: {detail['subject']}\n---\n{detail['text']}\n\n"
51
- return output
52
- except Exception as e:
53
- return f"Error: {str(e)}"
54
-
55
- # UI डिज़ाइन
56
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
57
- gr.Markdown("# 🛡️ 100% Working Private Temp Mail")
58
- token_state = gr.State("") # टोकन छुपा कर रखने के लिए
59
-
60
- with gr.Row():
61
- email_display = gr.Textbox(label="आपका पर्सनल ईमेल", interactive=False)
62
- gen_btn = gr.Button("🆕 Create New Email")
63
-
64
- inbox_area = gr.TextArea(label="📥 Messages", lines=10, interactive=False)
65
- refresh_btn = gr.Button("🔄 Refresh Inbox")
66
 
67
- def on_gen():
68
- email, token = create_mail()
69
- return email, token
 
 
 
70
 
71
- gen_btn.click(on_gen, outputs=[email_display, token_state])
72
- refresh_btn.click(check_inbox, inputs=token_state, outputs=inbox_area)
 
 
 
73
 
74
- demo.launch()
 
1
  import gradio as gr
2
  import requests
 
 
3
 
4
+ API_URL = "https://www.1secmail.com/api/v1/"
5
 
6
+ def get_edu_email():
7
+ # 1secmail के उपलब्ध डोमेन चेक करना
8
+ domains = requests.get(f"{API_URL}?action=getDomainList").json()
9
+ # लिस्ट में से .edu वाला डोमेन ढूंढना
10
+ edu_domain = next((d for d in domains if "edu" in d), None)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ if not edu_domain:
13
+ # अगर .edu नहीं मिला तो कोई भी रैंडम डोमेन उठा लेना
14
+ edu_domain = domains[0]
15
+ status = "⚠️ .edu डोमेन अभी उपलब्ध नहीं है, सामान्य डोमेन दिया गया है।"
16
+ else:
17
+ status = "✅ .edu डोमेन मिल गया!"
18
 
19
+ res = requests.get(f"{API_URL}?action=genAddrs&count=1").json()
20
+ # अपनी मर्ज़ी का नाम और Edu डोमेन जोड़ना
21
+ user = res[0].split('@')[0]
22
+ final_email = f"{user}@{edu_domain}"
23
+ return final_email, status
24
 
25
+ # बाकी का Inbox वाला फंक्शन वही रहेगा जो पहले था...