-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
53 lines (45 loc) · 1.48 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
from flask import Flask,render_template,request,redirect,url_for,session
from flask_mysqldb import MySQL
import MySQLdb
import sys
app=Flask(__name__)
app.config['MYSQL_HOST'] = "localhost"
app.config['MYSQL_USER'] = "root"
app.config['MYSQL_PASSWORD'] = "baba@159"
app.config['MYSQL_DB'] = "boycott_china"
mysql = MySQL(app)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/alternatives')
def alternative():
cur = mysql.connection.cursor()
cur.execute("select * from alternatives")
c_apps = cur.fetchall()
return render_template('alternative.html',result = c_apps)
@app.route('/Search',methods=["POST"])
def Search():
search = request.form['search']
cur = mysql.connection.cursor()
cur.execute("select * from alternatives where LOWER(chinese_app) LIKE '%"+search.lower()+"%'")
c_apps = cur.fetchall()
if c_apps:
return render_template('alternative.html',result = c_apps)
return render_template('tryAgain.html')
@app.route('/suggest')
def suggest():
return render_template('suggest.html')
@app.route('/getBig',methods = ['POST'])
def getBig():
Suggestion = {}
appName = request.form['AppName']
alternate = request.form['alternate']
Link = request.form['Link']
Suggestion['appName'] = appName
Suggestion['alternate'] = alternate
Suggestion['Link'] = Link
print(Suggestion)
sys.stdout.flush()
return render_template('thanks.html')
if __name__ == "__main__":
app.run(debug=True)