muhammadrazapathan commited on
Commit
56c3c26
·
verified ·
1 Parent(s): 034f645

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import os
4
+ from datetime import datetime
5
+
6
+ # File to store student data
7
+ DATA_FILE = "students.csv"
8
+
9
+ # Create file if not exists
10
+ if not os.path.exists(DATA_FILE):
11
+ df = pd.DataFrame(columns=["Name", "Email", "Department", "Message", "Time"])
12
+ df.to_csv(DATA_FILE, index=False)
13
+
14
+ # Function to save data
15
+ def submit_form(name, email, department, message):
16
+ if name.strip() == "" or email.strip() == "":
17
+ return "❌ Name and Email are required!"
18
+
19
+ new_data = pd.DataFrame([{
20
+ "Name": name,
21
+ "Email": email,
22
+ "Department": department,
23
+ "Message": message,
24
+ "Time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
25
+ }])
26
+
27
+ new_data.to_csv(DATA_FILE, mode="a", header=False, index=False)
28
+
29
+ return f"✅ Thank you {name}! Your response has been recorded."
30
+
31
+ # UI Design
32
+ with gr.Blocks(title="College Admission App") as app:
33
+ gr.Markdown("## 🎓 College Registration Form")
34
+ gr.Markdown("Fill the form below to register.")
35
+
36
+ name = gr.Textbox(label="Full Name")
37
+ email = gr.Textbox(label="Email Address")
38
+
39
+ department = gr.Dropdown(
40
+ ["Computer Science", "Business", "Engineering", "Mathematics", "Other"],
41
+ label="Select Department"
42
+ )
43
+
44
+ message = gr.Textbox(label="Why do you want to join?", lines=4)
45
+
46
+ submit_btn = gr.Button("Submit Application")
47
+
48
+ output = gr.Textbox(label="Status")
49
+
50
+ submit_btn.click(submit_form, inputs=[name, email, department, message], outputs=output)
51
+
52
+ app.launch()