-
Notifications
You must be signed in to change notification settings - Fork 0
/
new.py
52 lines (43 loc) · 1.52 KB
/
new.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
from flask import Flask,render_template,request
from pymongo import MongoClient as conns
import certifi
app = Flask(__name__)
conn = conns("mongodb+srv://admin:[email protected]/?retryWrites=true&w=majority&appName=nitmongoDB&ssl_cert_reqs=CERT_NONE",tlsCAFile=certifi.where())
db = conn['NITT']
coll=db['Bookings']
@app.route('/')
def index():
return render_template('index.html')
@app.route('/admin')
def admin():
return render_template('admin.html')
@app.route('/book',methods = ['GET','POST'])
def book():
if request.method== 'POST':
hd = {
'name':request.form.get('name'),
'hotel':request.form.get('hotel'),
'phone':request.form.get('phone'),
'ppn': int(request.form.get('ppn')),
'nop':int(request.form.get('nop'))
}
hotelData = coll.find_one({'name': hd['name']})
total_price =(int(hotelData['ppn']) * int ({hd['ppn']}) ) + (( int ({hd['nop']}) - int (hotelData['nop']) * 200 ))
@app.route('/addHotel', methods = ['GET','POST'])
def addHotel():
if request.method=='POST':
hd = {
'name':request.form.get('name'),
'city':request.form.get('loc'),
'phone':request.form.get('phone'),
'ppn': int(request.form.get('ppn')),
'nop':int(request.form.get('nop'))
}
coll.insert_one(hd)
print(' hotel data inserted')
return render_template('addHotel.html')
@app.route('/viewBookings')
def viewBooking():
return render_template('viewBookings.html',bookings=coll.find())
if __name__ == '__main__':
app.run(debug=True,port=4000)