Skip to content

Commit 76bae00

Browse files
authored
🐍
1 parent 2c48bf4 commit 76bae00

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

β€ŽOTP Verification.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Importing the libraries
2+
import twilio.rest
3+
import random
4+
from future.moves import tkinter
5+
from tkinter import messagebox
6+
7+
# Creating Window
8+
root = tkinter.Tk()
9+
root.title("OTP Verification")
10+
root.geometry("600x550")
11+
12+
# Twilio account details
13+
account_sid = ""
14+
auth_token = ""
15+
16+
17+
# resend the OTP
18+
def resendOTP():
19+
n = random.randint(1000, 9999)
20+
client = twilio.rest.Client(account_sid, auth_token)
21+
client.messages.create(to=[""], from_=" ", body=n)
22+
23+
24+
# Checking the OTP
25+
def checkOTP():
26+
global n
27+
try:
28+
user_input = int(user.get(1.0, "end01c"))
29+
if user_input == n:
30+
messagebox.showinfo("showinfo", "Login Success")
31+
n = "done"
32+
elif n == "done":
33+
messagebox.showinfo("showinfo", "Already entered")
34+
else:
35+
messagebox.showinfo("showinfo", "wrong OTP")
36+
except:
37+
messagebox.showinfo("showinfo", "Invalid OTP")
38+
39+
40+
# Drawing the canvas
41+
c = tkinter.Canvas(root, bg="white", width=400, height=300)
42+
c.place(x=100, y=60)
43+
44+
# Label widget
45+
login = tkinter.Label(root, text="OTP Verification", font="bold,20", bg="white")
46+
login.place(x=210, y=90)
47+
48+
# Entry widget
49+
user = tkinter.Text(root, borderwidth=2, wrap="word", width=29, height=2)
50+
user.place(x=190, y=160)
51+
52+
# Sending the otp
53+
n = random.randint(1000, 9999)
54+
client = twilio.rest.Client(account_sid, auth_token)
55+
client.messages.create(to=[""], from_="", body=n)
56+
57+
# Submit button
58+
submit_button = tkinter.Button(root, text="Submit", command=checkOTP(), font=('bold', 15))
59+
submit_button.place(x=258, y=250)
60+
61+
# Resend Button
62+
resend_button = tkinter.Button(root, text="Resend OTP", command=resendOTP(), font=("bold", 15))
63+
resend_button.place(x=240, y=400)
64+
65+
# Event Loop
66+
root.mainloop()

β€Žassets/python projects cover.png

46.4 KB
Loading

0 commit comments

Comments
Β (0)