-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
74 lines (61 loc) · 2.37 KB
/
main.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
from flask import Flask,render_template,request, redirect,url_for,jsonify
app = Flask(__name__)
from flaskext.mysql import MySQL
mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = ''
app.config['MYSQL_DATABASE_DB'] = 'Movie'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
@app.route('/deletemovie/<name>')
def deletemovie(name):
connection = mysql.get_db()
cursor = connection.cursor()
query="DELETE FROM moive where moviename = %s;"
cursor.execute(query,(name))
connection.commit()
return redirect(url_for('index'))
@app.route('/viewmovie')
def index():
cursor = mysql.connect().cursor()
cursor.execute("SELECT * from moive;")
data = cursor.fetchall();
return render_template("viewMovie.html", data=data)
@app.route('/addmovie',methods=['GET','POST'])
def addmovie():
if request.method=='POST':
moviename =request.form['moviename']
movietiming =request.form['movietiming']
movielocation =request.form['movielocation']
connection = mysql.get_db()
cursor = connection.cursor()
query="INSERT INTO moive(moviename,Location,timings) VALUES(%s,%s,%s)"
cursor.execute(query,(moviename,movielocation,movietiming))
connection.commit()
return redirect(url_for('index'))
return render_template("addMovie.html")
@app.route('/editmovie/<name>',methods=['GET','POST'])
def editmovie(name):
connection = mysql.get_db()
cursor = connection.cursor()
query="select * from moive where movieName = %s"
cursor.execute(query,(name))
data =cursor.fetchall()
connection.commit()
return render_template("editMovie.html", data=data)
##return render_template("editMovie.html",item = data)
@app.route('/updatemovie',methods=['GET','POST'])
def updatemovie():
if request.method=='POST':
moviename =request.form['moviename']
movietiming =request.form['movietiming']
movielocation =request.form['movielocation']
connection = mysql.get_db()
cursor = connection.cursor()
query="UPDATE moive SET Location = %s,timings = %s where moviename = %s "
cursor.execute(query,(movielocation,movietiming,moviename))
connection.commit()
return redirect(url_for('index'))
if __name__ == '__main__':
app.run(debug = True)