代码拉取完成,页面将自动刷新
from flask import Flask,render_template,jsonify,request
from random import randint
app = Flask(__name__)
def rand_five_percent():
rel = randint(1,5)
if rel ==5:
return True
return False
def rand_ten_percent():
rel = randint(1,10)
if rel == 5:
return True
return False
def rand_fiften_percent():
rel = randint(1,15)
if rel == 5:
return True
return False
def rand_twenty_percent():
rel = randint(1,20)
if rel == 5:
return True
return False
@app.route("/")
def index():
for x in range(10000):
rand_five_percent()
return "ok"
@app.route("/api/test/probability")
def random_app():
value = request.values
amount = value.get("amount")
data = {
"status":True
}
try:
amount = int(amount)
except Exception as e:
data["status"] = False
data["err_msg"] = e.args
return jsonify(data)
if amount<500:
rel = rand_five_percent()
elif amount >= 500 and amount< 1000:
rel = rand_ten_percent()
elif amount >1000 and amount <2000:
rel = rand_fiften_percent()
else:
rel = rand_twenty_percent()
data["data"] = {
"win":rel
}
return jsonify(data)
@app.route("/api/login")
def login_func():
forms = request.values
username = forms.get("username")
password = forms.get("password")
print(username)
print(password)
if username=="wo" and password == "ni":
return jsonify({"status":True})
else:
return jsonify({"status":False})
@app.route("/api/login2",methods=["POST","GET"])
def login_func2():
if request.method == "POST":
forms = request.values
username = forms.get("username")
password = forms.get("password")
print(username)
print(password)
if username=="wo" and password == "ni":
return jsonify({"status":True})
else:
return jsonify({"status":False})
elif request.method == "GET":
return jsonify({"status":False,"err_msg":"请求不合法"})
if __name__ == "__main__":
app.run(host="0.0.0.0",port=8800,debug=True)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。