-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyshoppingdir.py
More file actions
88 lines (63 loc) · 2.21 KB
/
myshoppingdir.py
File metadata and controls
88 lines (63 loc) · 2.21 KB
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
from flask import Flask, render_template, request, redirect, url_for
import sqlite3
app = Flask(__name__)
@app.route('/main')
def mainstream():
return render_template('MainPage.html', items = None)
@app.route('/brand')
def showbrand(brand=None):
db = sqlite3.connect('mydatabase.db')
db.row_factory = sqlite3.Row
items = db.execute(
'select bName, location, scale from brand'
).fetchall()
db.close()
return render_template('Brandlist.html', items = items)
@app.route('/platform')
def showplatform(platform=None):
db = sqlite3.connect('mydatabase.db')
db.row_factory = sqlite3.Row
items = db.execute(
'select pName, event, salesrank from salesplatform'
).fetchall()
db.close()
return render_template('Platformlist.html', items = items)
@app.route('/goods', methods = ['GET', 'POST'])
def searchgoods(items=None):
return render_template('searchgoods.html')
@app.route('/results/<string:argclass>/<string:argcolor>/', methods = ['GET', 'POST'])
def searchresults(argclass, argcolor):
db = sqlite3.connect('mydatabase.db')
db.row_factory = sqlite3.Row
items = db.execute(
'select goodsID, class, color, launchingby, price'
'from clothes'
'where class=?' (argclass)
).fetchall()
db.close()
return render_template('searchresults.html', items = items)
@app.route('/brand/edit/<string:brandname>/', methods=['GET','POST'])
def editBrand(brandname):
if request.method=='POST':
db = sqlite3.connect("mydatabase.db")
db.row_factory = sqlite3.Row
db.execute(
'update brand'
' set location=?'
' where bName=?',
(request.form['location'],brandname)
)
db.commit()
db.close()
return redirect(url_for('showbrand'))
else:
db = sqlite3.connect("mydatabase.db")
db.row_factory = sqlite3.Row
item = db.execute(
'select bName, location, scale from brand where bName=?',(brandname)
).fetchone()
db.close()
return render_template('editBrand.html', item=item)
if __name__ == '__main__':
app.debug = True
app.run(host='127.0.0.1', port=5000)