Skip to content

Commit bd3eeff

Browse files
authored
Merge pull request #15 from ldqLDQ/dev
added ks
2 parents 73db060 + 2998452 commit bd3eeff

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from users import *
44
from publish import *
55
from search import *
6+
from ks import *
67

78
app = Flask(__name__)
89
api = Api(app)
@@ -109,6 +110,7 @@ def post(self):
109110
api.add_resource(Detail, '/detail/<int:tid>', endpoint='Detail')
110111
api.add_resource(MyPublished, '/my/published', endpoint='MyPublished')
111112
api.add_resource(MyJoined, '/my/joined', endpoint='MyJoined')
113+
api.add_resource(ks, '/ks', endpoint='ks')
112114
# api.add_resource(TestSearch, '/test/search', endpoint='testsearch')
113115
# 不再返回测试数据
114116

ks.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import random
2+
from flask_restful import Resource, reqparse
3+
minA = 1000
4+
maxA = 9999
5+
minB = 100
6+
maxB = 9999
7+
minC = 2
8+
maxC = 9
9+
10+
11+
class ks(Resource):
12+
"""
13+
Author: ldqLDQ
14+
功能: 获取一用户已发布的自习列表
15+
"""
16+
def get(self):
17+
def newPlus():
18+
A = random.randint(minA,maxA)
19+
B = random.randint(minB,maxB)
20+
S = A+B
21+
return str(A)+" + "+str(B)
22+
def newMinus():
23+
A = random.randint(minA,maxA)
24+
B = random.randint(minB,A)
25+
S = A-B
26+
return str(A)+" - "+str(B)
27+
def newMulti():
28+
A0 = random.randint(minA,maxA)
29+
B = random.randint(minC,maxC)
30+
A = int(A0/B)
31+
S = A*B
32+
return str(A)+" × "+str(B)
33+
def newDivi():
34+
A = random.randint(minA,maxA)
35+
B = random.randint(minC,maxC)
36+
#S = A+B
37+
return str(A)+" ÷ "+str(B)
38+
39+
s = []
40+
s.append(newPlus())
41+
s.append(newMinus())
42+
s.append(newMulti())
43+
s.append(newDivi())
44+
random.shuffle(s)
45+
r = {1:s[0], 2:s[1], 3:s[2], 4:s[3]}
46+
return r

0 commit comments

Comments
 (0)