-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
100 lines (89 loc) · 3.54 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from flask import Flask, render_template,url_for,request
import pyodbc
conn = pyodbc.connect('Driver={SQL Server};'
'Server=MOINAK;'
'Database=NGO;'
'Trusted_Connection=yes;'
)
cur = conn.cursor()
app = Flask(__name__)
@app.route('/')
def home():
# put application's code here
return render_template('index.html')
@app.route("/donate", methods=['GET','POST'])
def donate():
if request.method == 'POST':
userDetails =request.form
Name = userDetails['name']
Age= userDetails['age']
Aadhar=userDetails['aadhar']
Phone=userDetails['phone']
City=userDetails['city']
Address=userDetails['address']
Item=userDetails['item']
Quantity=userDetails['quantity']
Amount =userDetails['amount']
cur.execute(" INSERT INTO Donor(Name, Age,Aadhar, Phone, City, Address) VALUES(?,?,?,?,?,?)",(Name,Age,Aadhar,Phone,City,Address))
cur.commit()
cur.execute("INSERT INTO Donation(Aadhar,Item_donated,Item_quantity,Amount_donated) VALUES(?,?,?,?)",(Aadhar,Item,Quantity,Amount))
cur.commit()
cur.execute("SELECT * fROM Ngo where City=(?) ", (City))
data = cur.fetchall()
return render_template("List.html", ngo=data)
return render_template('Form.html')
@app.route("/volunteer", methods=['GET','POST'])
def volunteer():
if request.method == 'POST':
VolunteerDetails =request.form
Name = VolunteerDetails['name']
Age= VolunteerDetails['age']
Gender=VolunteerDetails['gender']
Aadhar = VolunteerDetails['aadhar']
Phone=VolunteerDetails['phone']
City=VolunteerDetails['city']
Address=VolunteerDetails['address']
cur.execute(" INSERT INTO Volunteer(Name, Age,Gender,Aadhar, Phone, City, Address) VALUES(?,?,?,?,?,?,?)",(Name,Age,Gender,Aadhar,Phone,City,Address))
cur.commit()
cur.execute("SELECT * fROM Ngo where City=(?) ", (City))
data = cur.fetchall()
return render_template("List.html", ngo=data)
return render_template('V_form.html')
@app.route("/old_donor",methods=['GET','POST'])
def old_donor():
if request.method == 'POST':
n_data=request.form
Aadhar=n_data['aadhar']
Item = n_data['item']
Quantity = n_data['quantity']
Amount = n_data['amount']
cur.execute("INSERT INTO Donation(Aadhar,Item_donated,Item_quantity,Amount_donated) VALUES(?,?,?,?)",(Aadhar,Item,Quantity,Amount))
cur.commit()
return render_template("O_form.html")
@app.route("/regNgo",methods=['GET','POST'])
def regngo():
if request.method =='POST':
r_data=request.form
Name=r_data['name']
Work=r_data['work']
Phone=r_data['phone']
City=r_data['city']
State=r_data['state']
cur.execute(" INSERT INTO NGO(Ngo_Name,Ngo_Workfield,Phone,City,State) VALUES (?,?,?,?,?)",(Name,Work,Phone,City,State))
cur.commit()
return render_template('N_form.html')
# @app.route("/list",methods=['GET','POST'])
# def list():
# if request.method == 'POST':
# n_data=request.form
# City = n_data['city']
# cur.execute("SELECT * fROM Ngo where City=(?) ",(City))
# data =cur.fetchall()
# if data == 0:
# print(data)
# return render_template("List.html",ngo=data)
# cur.execute("SELECT * fROM Ngo")
# data = cur.fetchall()
# return render_template("List.html",ngo=data)
if __name__ == '__main__':
app.run(debug=True)