-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
70 lines (50 loc) · 1.31 KB
/
views.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
from flask import render_template,request,jsonify
import json
from src import app
@app.route('/')
def index():
return render_template('index.html')
@app.route('/mystring')
def mystring():
return 'my string'
@app.route('/dataFormAjax')
def dataFromAjax():
test = request.args.get('mydata')
print(test)
return 'dataFromAjax'
@app.route('/mydict',methods=['GET','POST'])
def mydict():
if request.method == 'POST':
a = request.form['mydata']
print(a)
d = {'name':'jjj','age':18}
return jsonify(d)
@app.route('/name',methods=['POST'])
def getname():
firstname = request.form['firstname']
lastname = request.form['lastname']
d = {'name':firstname + ' ' + lastname,'age': 18}
print(d)
return jsonify(d)
@app.route('/myform',methods=['POST'])
def myform():
print('post')
a = request.form['FirstName']
print(a)
d = {'name': 'xmr', 'age': 18}
return jsonify(d)
@app.route('/mylist')
def mylist():
l = ['xmr',18]
print('mylist')
return json.dumps(l)
@app.route('/mytable')
def mytable():
table = [('id', 'name', 'age', 'score'),
('1', 'xiemanrui', '18', '100'),
('2', 'yxx', '18', '100'),
('3', 'yaoming', '37', '88')]
print('mytable')
data = json.dumps(table)
print(data)
return data