flask 开发接口测试平台
flask 开发接口测试平台
数据库,forms views 视图,
数据库如下:
# encoding: utf-8
'''
@author: lileilei
@file: models.py
@time: 2017/5/6 19:28
'''
from app import db
import datetime
from werkzeug.security import generate_password_hash,check_password_hash
class User(db.Model):#用户表
uer_id=db.Column(db.Integer,primary_key=True,autoincrement=True)#用户id
user_name=db.Column(db.String(64))#用户名
password=db.Column(db.String(64))#用户密码
status=db.Column(db.Integer)
level=db.Column(db.Integer)
user_zhuce_date=db.Column(db.DateTime,default=datetime.datetime.now())#注册时间
user_zhuce_email=db.Column(db.String(64))#注册ip
user_iphone=db.Column(db.Integer)#手机号
user_qq=db.Column(db.Integer)#qq
def __repr__(self):
return '<User %r>' % self.user_name
def set_password(self, password):
self.password = generate_password_hash(password)
def check_password(self, password):
return check_password_hash(self.password, password)
class Model(db.Model):#模块
model_id=db.Column(db.Integer,primary_key=True,autoincrement=True)
model_name = db.Column(db.String(256))
status = db.Column(db.Integer)
class Interface(db.Model):#接口
interface_id=db.Column(db.Integer,primary_key=True,autoincrement=True)
model_id=db.Column(db.Integer,db.ForeignKey('model.model_id'))#对应模块的名字
interface_name=db.Column(db.String(64))#接口名字
interface_url=db.Column(db.String(1024))#接口地址
interface_methd=db.Column(db.String(64))#接口请求方式
request_exam=db.Column(db.String(4096))#请求
reposnese_exam=db.Column(db.String(4096))#返回
stasus=db.Column(db.Integer)#状态
def __repr__(self):
return '<Interface name is :%r>'%self.interface_name
class Parameter(db.Model):
parameter_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
interface_id = db.Column(db.Integer, db.ForeignKey("interface.interface_id"))
parameter_type = db.Column(db.String(64))
parameter_group_id = db.Column(db.Integer)
parameter_name = db.Column(db.String(64))
necessary = db.Column(db.String(64))
type = db.Column(db.String(64))
default = db.Column(db.String(64))
remark = db.Column(db.String(64))
level = db.Column(db.String(64))
views 视图函数如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from flask import render_template, redirect, session, url_for,flash,request
from app import app
from app import db
from .models import Interface, Model, User, Parameter
from .forms import LoginForm, ReguistForm,ModelForm, InterfaceForm, ParameterRequestForm, ParameterResponseForm, SubmitForm
import datetime
# 前台首页
@app.route("/", methods=["GET", "POST"])
@app.route("/index", methods=["GET", "POST"])
def index():
return render_template("index.html")
# 前台模块列表
@app.route("/font", methods=["GET", "POST"])
def front():
model_all = Model.query.all()
model_forms = []
for i in range(len(model_all)):
model_form = {"model_id": model_all[i].model_id,
"model_name": model_all[i].model_name}
model_forms.append(model_form)
return render_template("front.html",
model_forms=model_forms)
# 前台接口列表
@app.route("/front_model/<model_id>", methods=["GET", "POST"])
def front_model(model_id):
model_one = Model.query.filter_by(model_id=model_id).first()
interface_model_all = Interface.query.filter_by(model_id=model_id).all()
interface_model_forms = []
for i in range(len(interface_model_all)):
interface_model_form = {"interface_id": interface_model_all[i].interface_id,
"interface_name": interface_model_all[i].interface_name,
"interface_url": interface_model_all[i].interface_url}
interface_model_forms.append(interface_model_form)
return render_template("front_model.html",
model_id=model_id,
model_one=model_one,
interface_model_forms=interface_model_forms)
g_parameter_request = []
g_parameter_response = []
# 前台接口详情
@app.route("/front_interface/<model_id>&<interface_id>", methods=["GET", "POST"])
def front_interface(model_id, interface_id):
global g_parameter_request, g_parameter_response
model_one = Model.query.filter_by(model_id=model_id).first()
interface_model_all = Interface.query.filter_by(model_id=model_id).all()
interface_model_one = Interface.query.filter_by(interface_id=interface_id).first()
interface_model_forms = []
for i in range(len(interface_model_all)):
interface_model_form = {"interface_id": interface_model_all[i].interface_id,
"interface_name": interface_model_all[i].interface_name,
"interface_url": interface_model_all[i].interface_url}
interface_model_forms.append(interface_model_form)
parameter_request_all = Parameter.query.filter_by(interface_id=interface_id, parameter_type=10).all()
parameter_request_forms = []
for i in range(len(parameter_request_all)):
parameter_request_form = {"parameter_id": parameter_request_all[i].parameter_id,
"parameter_name": parameter_request_all[i].parameter_name,
"necessary": parameter_request_all[i].necessary,
"type": parameter_request_all[i].type,
"default": parameter_request_all[i].default,
"remark": parameter_request_all[i].remark,
"parameter_group_id": parameter_request_all[i].parameter_group_id,
"level": parameter_request_all[i].level}
parameter_request_forms.append(parameter_request_form)
parameter_response_all = Parameter.query.filter_by(interface_id=interface_id, parameter_type=20).all()
parameter_response_forms = []
for i in range(len(parameter_response_all)):
parameter_response_form = {"parameter_id": parameter_response_all[i].parameter_id,
"parameter_name": parameter_response_all[i].parameter_name,
"necessary": parameter_response_all[i].necessary,
"type": parameter_response_all[i].type,
"default": parameter_response_all[i].default,
"remark": parameter_response_all[i].remark,
"parameter_group_id": parameter_response_all[i].parameter_group_id,
"level": parameter_response_all[i].level}
parameter_response_forms.append(parameter_response_form)
g_parameter_request = [] # 全局变量、清空列表数据
g_parameter_response = [] # 全局变量、清空列表数据
n_parameter_request(parameter_request_forms, parameter_request_all[0].parameter_group_id)
n_parameter_response(parameter_response_forms,parameter_response_all[0].parameter_group_id)
return render_template("front_interface.html",
model_id=model_id,
model_one=model_one,
interface_model_forms=interface_model_forms,
interface_model_one=interface_model_one,
g_parameter_request=g_parameter_request,
g_parameter_response=g_parameter_response)
# 请求参数排序
def n_parameter_request(request, parameter_group_id):
for form in request:
if form["parameter_group_id"] == parameter_group_id:
new_parameter_group_id = form["parameter_id"]
g_parameter_request.append(form)
n_parameter_request(request, new_parameter_group_id)
return g_parameter_request
# 返回参数排序
def n_parameter_response(response, parameter_group_id):
for form in response:
if form["parameter_group_id"] == parameter_group_id:
new_parameter_group_id = form["parameter_id"]
g_parameter_response.append(form)
n_parameter_response(response, new_parameter_group_id)
return g_parameter_response
# 后台首页
@app.route("/home", methods=["GET", "POST"])
def home():
if not session.get("logged_in"):
return redirect(url_for("login"))
return render_template("home.html")
# 后台登录
@app.route("/login", methods=["GET", "POST"])
def login():
form = LoginForm()
if form.validate_on_submit():
try:
user_one = User.query.filter_by(user_name=form.username.data).first()
me=user_one.check_password(form.password.data)
if me==True and user_one.status == 1:
session["logged_in"] = True
return redirect(url_for("home"))
else:
flash('登录密码错误!请检测你的密码')
return render_template("login.html", form=form)
except AttributeError:
flash('登录fail!')
return render_template("login.html", form=form)
return render_template("login.html",
form=form)
# 后台登出
@app.route("/logout", methods=["GET", "POST"])
def logout():
session.pop("logged_in", None)
return redirect(url_for("index"))
# 模块管理
@app.route("/model", methods=["GET", "POST"])
def model():
if not session.get("logged_in"):
return redirect(url_for("login"))
model_all = Model.query.all()
model_forms = []
for i in range(len(model_all)):
model_form = {"model_id": model_all[i].model_id,
"model_name": model_all[i].model_name}
model_forms.append(model_form)
return render_template("model.html",
model_forms=model_forms)
# 新增模块
@app.route("/addmodel", methods=["GET", "POST"])
def addmodel():
if not session.get("logged_in"):
return redirect(url_for("login"))
add_model = ModelForm()
submit = SubmitForm()
if submit.validate_on_submit():
add = Model(model_name=add_model.model_name.data)
db.session.add(add)
db.session.commit()
return redirect(url_for("model"))
return render_template("addmodel.html",
add_model=add_model,
submit=submit)
# 编辑模块
@app.route("/editmodel/<model_id>", methods=["GET", "POST"])
def editmodel(model_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
model_one = Model.query.filter_by(model_id=model_id).first()
edit_model = ModelForm()
submit = SubmitForm()
if submit.validate_on_submit():
model_one.model_name = edit_model.model_name.data
db.session.commit()
return redirect(url_for("model"))
edit_model.model_name.data = model_one.model_name
return render_template("editmodel.html",
edit_model=edit_model,
submit=submit)
# 接口列表
@app.route("/interface/<model_id>")
def interface(model_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
interface_model_all = Interface.query.filter_by(model_id=model_id).all()
interface_model_forms = []
for i in range(len(interface_model_all)):
interface_model_form = {"interface_id": interface_model_all[i].interface_id,
"interface_name": interface_model_all[i].interface_name,
"interface_url": interface_model_all[i].interface_url}
interface_model_forms.append(interface_model_form)
return render_template("interface.html",
model_id=model_id,
interface_model_forms=interface_model_forms)
# 新增接口
@app.route("/addinterface/<model_id>", methods=["GET", "POST"])
def addinterface(model_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
add_interface = InterfaceForm()
submit = SubmitForm()
if submit.validate_on_submit():
add = Interface(interface_name=add_interface.interface_name.data,
model_id=model_id,
interface_url=add_interface.interface_url.data,
interface_methd=add_interface.interface_method.data,
request_exam=add_interface.request_exam.data,
reposnese_exam=add_interface.response_exam.data)
db.session.add(add)
db.session.commit()
return redirect(url_for("interface",
model_id=model_id))
return render_template("addinterface.html",
add_interface=add_interface,
model_id=model_id,
submit=submit)
# 编辑接口
@app.route("/editinterface/<model_id>&<interface_id>", methods=["GET", "POST"])
def editinterface(model_id, interface_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
interface_model_one = Interface.query.filter_by(interface_id=interface_id).first()
edit_interface_model = InterfaceForm()
submit = SubmitForm()
if submit.validate_on_submit():
interface_model_one.interface_name = edit_interface_model.interface_name.data
interface_model_one.interface_url = edit_interface_model.interface_url.data
interface_model_one.interface_methd = edit_interface_model.interface_method.data
interface_model_one.request_exam = edit_interface_model.request_exam.data
interface_model_one.response_exam = edit_interface_model.response_exam.data
db.session.commit()
return redirect(url_for("interface",
model_id=model_id))
edit_interface_model.interface_name.data = interface_model_one.interface_name
edit_interface_model.interface_url.data = interface_model_one.interface_url
edit_interface_model.interface_method.data = interface_model_one.interface_methd
edit_interface_model.request_exam.data = interface_model_one.request_exam
edit_interface_model.response_exam.data = interface_model_one.reposnese_exam
return render_template("editinterface.html",
model_id=model_id,
interface_id=interface_id,
edit_interface_model=edit_interface_model,
submit=submit)
# 请求参数列表
@app.route("/parameter_request/<model_id>&<interface_id>", methods=["GET", "POST"])
def parameter_request(model_id, interface_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
parameter_request_all = Parameter.query.filter_by(interface_id=interface_id, parameter_type=10).all()
parameter_request_forms = []
for i in range(len(parameter_request_all)):
parameter_request_form = {"parameter_id": parameter_request_all[i].parameter_id,
"parameter_name": parameter_request_all[i].parameter_name,
"necessary": parameter_request_all[i].necessary,
"type": parameter_request_all[i].type,
"default": parameter_request_all[i].default,
"remark": parameter_request_all[i].remark,
"parameter_group_id": parameter_request_all[i].parameter_group_id,
"level": parameter_request_all[i].level}
parameter_request_forms.append(parameter_request_form)
return render_template("parameter_request.html",
model_id=model_id,
interface_id=interface_id,
parameter_request_forms=parameter_request_forms)
# 新增请求参数
@app.route("/addparameter_request/<model_id>&<interface_id>", methods=["GET", "POST"])
def addparameter_request(model_id, interface_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
add_parameter_request = ParameterRequestForm()
submit = SubmitForm()
if submit.validate_on_submit():
add = Parameter(interface_id=interface_id,
parameter_type=10,
parameter_group_id=add_parameter_request.parameter_group_id.data,
parameter_name=add_parameter_request.parameter_name.data,
necessary=add_parameter_request.necessary.data,
type=add_parameter_request.type.data,
default=add_parameter_request.default.data,
remark=add_parameter_request.remark.data,
level=add_parameter_request.level.data)
db.session.add(add)
db.session.commit()
return redirect(url_for("parameter_request",
model_id=model_id,
interface_id=interface_id))
return render_template("addparameter_request.html",
add_parameter_request=add_parameter_request,
model_id=model_id,
interface_id=interface_id,
submit=submit)
# 编辑请求参数
@app.route("/editparameter_request/<model_id>&<interface_id>&<parameter_id>", methods=["GET", "POST"])
def editparameter_request(model_id, interface_id, parameter_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
parameter_request_one = Parameter.query.filter_by(parameter_id=parameter_id).first()
edit_parameter_request = ParameterRequestForm()
submit = SubmitForm()
if submit.validate_on_submit():
parameter_request_one.parameter_name = edit_parameter_request.parameter_name.data
parameter_request_one.necessary = edit_parameter_request.necessary.data
parameter_request_one.type = edit_parameter_request.type.data
parameter_request_one.default = edit_parameter_request.default.data
parameter_request_one.remark = edit_parameter_request.remark.data
parameter_request_one.parameter_group_id = edit_parameter_request.parameter_group_id.data
parameter_request_one.level = edit_parameter_request.level.data
db.session.commit()
return redirect(url_for("parameter_request",
model_id=model_id,
interface_id=interface_id))
edit_parameter_request.parameter_name.data = parameter_request_one.parameter_name
edit_parameter_request.necessary.data = parameter_request_one.necessary
edit_parameter_request.type.data = parameter_request_one.type
edit_parameter_request.default.data = parameter_request_one.default
edit_parameter_request.remark.data = parameter_request_one.remark
edit_parameter_request.parameter_group_id.data = parameter_request_one.parameter_group_id
edit_parameter_request.level.data = parameter_request_one.level
return render_template("editparameter_request.html",
model_id=model_id,
interface_id=interface_id,
parameter_id=parameter_id,
edit_parameter_request=edit_parameter_request,
submit=submit)
# 删除请求参数
@app.route("/deleteparameter_request/<model_id>&<interface_id>&<parameter_id>", methods=["GET", "POST"])
def deleteparameter_request(model_id, interface_id, parameter_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
deleteparameter_request_one = Parameter.query.filter_by(parameter_id=parameter_id).first()
db.session.delete(deleteparameter_request_one)
db.session.commit()
parameter_request_all = Parameter.query.filter_by(interface_id=interface_id, parameter_type=10).all()
parameter_request_forms = []
for i in range(len(parameter_request_all)):
parameter_request_form = {"parameter_id": parameter_request_all[i].parameter_id,
"parameter_name": parameter_request_all[i].parameter_name,
"necessary": parameter_request_all[i].necessary,
"type": parameter_request_all[i].type,
"default": parameter_request_all[i].default,
"remark": parameter_request_all[i].remark,
"parameter_group_id": parameter_request_all[i].parameter_group_id,
"level": parameter_request_all[i].level}
parameter_request_forms.append(parameter_request_form)
return render_template("parameter_request.html",
model_id=model_id,
interface_id=interface_id,
parameter_request_forms=parameter_request_forms)
# 返回参数列表
@app.route("/parameter_response/<model_id>&<interface_id>", methods=["GET", "POST"])
def parameter_response(model_id, interface_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
parameter_response_all = Parameter.query.filter_by(interface_id=interface_id, parameter_type=20).all()
parameter_response_forms = []
for i in range(len(parameter_response_all)):
parameter_response_form = {"parameter_id": parameter_response_all[i].parameter_id,
"parameter_name": parameter_response_all[i].parameter_name,
"necessary": parameter_response_all[i].necessary,
"type": parameter_response_all[i].type,
"default": parameter_response_all[i].default,
"remark": parameter_response_all[i].remark,
"parameter_group_id": parameter_response_all[i].parameter_group_id,
"level": parameter_response_all[i].level}
parameter_response_forms.append(parameter_response_form)
return render_template("parameter_response.html",
model_id=model_id,
interface_id=interface_id,
parameter_response_forms=parameter_response_forms)
# 新增返回参数
@app.route("/addparameter_response/<model_id>&<interface_id>", methods=["GET", "POST"])
def addparameter_response(model_id, interface_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
add_parameter_response = ParameterResponseForm()
submit = SubmitForm()
if submit.validate_on_submit():
add = Parameter(interface_id=interface_id,
parameter_type=20,
parameter_group_id=add_parameter_response.parameter_group_id.data,
parameter_name=add_parameter_response.parameter_name.data,
necessary=add_parameter_response.necessary.data,
type=add_parameter_response.type.data,
default=add_parameter_response.default.data,
remark=add_parameter_response.remark.data,
level=add_parameter_response.level.data)
db.session.add(add)
db.session.commit()
return redirect(url_for("parameter_response",
model_id=model_id,
interface_id=interface_id))
return render_template("addparameter_response.html",
add_parameter_response=add_parameter_response,
model_id=model_id,
interface_id=interface_id,
submit=submit)
# 编辑返回参数
@app.route("/editparameter_response/<model_id>&<interface_id>&<parameter_id>", methods=["GET", "POST"])
def editparameter_response(model_id, interface_id, parameter_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
parameter_response_one = Parameter.query.filter_by(parameter_id=parameter_id).first()
edit_parameter_response = ParameterResponseForm()
submit = SubmitForm()
if submit.validate_on_submit():
parameter_response_one.parameter_name = edit_parameter_response.parameter_name.data
parameter_response_one.necessary = edit_parameter_response.necessary.data
parameter_response_one.type = edit_parameter_response.type.data
parameter_response_one.default = edit_parameter_response.default.data
parameter_response_one.remark = edit_parameter_response.remark.data
parameter_response_one.parameter_group_id = edit_parameter_response.parameter_group_id.data
parameter_response_one.level = edit_parameter_response.level.data
db.session.commit()
return redirect(url_for("parameter_response",
model_id=model_id,
interface_id=interface_id))
edit_parameter_response.parameter_name.data = parameter_response_one.parameter_name
edit_parameter_response.necessary.data = parameter_response_one.necessary
edit_parameter_response.type.data = parameter_response_one.type
edit_parameter_response.default.data = parameter_response_one.default
edit_parameter_response.remark.data = parameter_response_one.remark
edit_parameter_response.parameter_group_id.data = parameter_response_one.parameter_group_id
edit_parameter_response.level.data = parameter_response_one.level
return render_template("editparameter_response.html",
model_id=model_id,
interface_id=interface_id,
parameter_id=parameter_id,
edit_parameter_response=edit_parameter_response,
submit=submit)
# 删除返回参数
@app.route("/deleteparameter_response/<model_id>&<interface_id>&<parameter_id>", methods=["GET", "POST"])
def deleteparameter_response(model_id, interface_id, parameter_id):
if not session.get("logged_in"):
return redirect(url_for("login"))
deleteparameter_response_one = Parameter.query.filter_by(parameter_id=parameter_id).first()
db.session.delete(deleteparameter_response_one)
db.session.commit()
parameter_response_all = Parameter.query.filter_by(interface_id=interface_id, parameter_type=20).all()
parameter_response_forms = []
for i in range(len(parameter_response_all)):
parameter_response_form = {"parameter_id": parameter_response_all[i].parameter_id,
"parameter_name": parameter_response_all[i].parameter_name,
"necessary": parameter_response_all[i].necessary,
"type": parameter_response_all[i].type,
"default": parameter_response_all[i].default,
"remark": parameter_response_all[i].remark,
"parameter_group_id": parameter_response_all[i].parameter_group_id,
"level": parameter_response_all[i].level}
parameter_response_forms.append(parameter_response_form)
return render_template("parameter_response.html",
model_id=model_id,
interface_id=interface_id,
parameter_response_forms=parameter_response_forms)
# 用户管理
@app.route("/users", methods=["GET", "POST"])
def user():
if not session.get("logged_in"):
return redirect(url_for("login"))
user_all = User.query.filter_by(status=1).all()
user_forms = []
for i in range(len(user_all)):
user_form = {"user_id": user_all[i].uer_id,
"user_name": user_all[i].user_name,
"password": user_all[i].password[:30],
"status": user_all[i].status,
"level": user_all[i].level,
"user_zhuce_date": user_all[i].user_zhuce_date,
"user_zhuce_email": user_all[i].user_zhuce_email,
"user_iphone": user_all[i].user_iphone,
"user_qq": user_all[i].user_qq
}
user_forms.append(user_form)
return render_template("user_admin.html",
user_forms=user_forms)
#注册
@app.route('/register',methods=['GET','POST'])
def registser():
form = ReguistForm()
if form.validate_on_submit():
user=form.user_name.data
me=User.query.filter_by(user_name=user).first()
if me:
flash('用户名已经存在!')
return render_template('regist.html',form=form)
if form.que_password.data != form.password.data:
flash(' 确认密码是否一致!')
return render_template('regist.html',form=form)
passw=form.password.data
print(passw)
add=User(
user_name=form.user_name.data,
status=1,
user_zhuce_email=form.email.data,
user_iphone=form.iphone.data,
user_qq=form.qq.data,
user_zhuce_date=datetime.datetime.now()
)
add.set_password(password=passw)
db.session.add(add)
db.session.commit()
return redirect(url_for('login'))
return render_template("regist.html",
form=form)
#删除用户
@app.route('/delete/<user_name>',methods=['GET','POST'])
def delete(user_name):
if not session.get("logged_in"):
return redirect(url_for("login"))
delete_user=User.query.filter_by(user_name=user_name).first()
db.session.delete(delete_user)
db.session.commit()
user_all = User.query.filter_by(status=1).all()
user_forms = []
for i in range(len(user_all)):
user_form = {"user_id": user_all[i].uer_id,
"user_name": user_all[i].user_name,
"password": user_all[i].password[:30],
"status": user_all[i].status,
"level": user_all[i].level,
"user_zhuce_date": user_all[i].user_zhuce_date,
"user_zhuce_email": user_all[i].user_zhuce_email,
"user_iphone": user_all[i].user_iphone,
"user_qq": user_all[i].user_qq
}
user_forms.append(user_form)
return render_template("user_admin.html",
user_forms=user_forms)
forms 表单代码如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*- from flask_wtf import Form
from wtforms import StringField, TextField, PasswordField, FormField, SubmitField, FieldList, IntegerField
from wtforms.validators import Required, DataRequired class LoginForm(Form):
username = StringField("登陆名", validators=[Required()])
password = PasswordField("密码", validators=[Required()]) class ModelForm(Form):
model_name = StringField("中文名称", validators=[Required()]) class InterfaceForm(Form):
interface_name = StringField("接口名称", validators=[Required()])
interface_url = StringField("接口地址", validators=[Required()])
interface_method = StringField("接口方法", validators=[Required()])
request_exam = TextField("请求示例", validators=[Required()])
response_exam = TextField("返回示例", validators=[Required()]) class ParameterRequestForm(Form):
parameter_group_id = StringField("从属", validators=[Required()])
parameter_name = StringField("参数名称", validators=[Required()])
necessary = StringField("是否必须", validators=[Required()])
type = StringField("类型", validators=[Required()])
default = StringField("默认值", validators=[Required()])
remark = StringField("备注", validators=[Required()])
level = StringField("层级", validators=[Required()]) class ParameterResponseForm(Form):
parameter_group_id = StringField("从属", validators=[Required()])
parameter_name = StringField("参数名称", validators=[Required()])
necessary = StringField("是否必须", validators=[Required()])
type = StringField("类型", validators=[Required()])
default = StringField("示例", validators=[Required()])
remark = StringField("描述", validators=[Required()])
level = StringField("层级", validators=[Required()]) class SubmitForm(Form):
submit = SubmitField("保存") class ReguistForm(Form):#注册
user_name=StringField('用户名',validators=[Required()])
password=PasswordField('密码',validators=[Required()])
que_password=PasswordField('密码',validators=[Required()])
iphone=IntegerField('手机号',validators=[Required()])
qq=IntegerField('qq号',validators=[Required()])
email=StringField('邮箱',validators=[Required()])
效果如下图:
原文地址:https://www.cnblogs.com/leiziv5/p/6830256.html
git地址https://github.com/liwanlei/plmock
flask 开发接口测试平台的更多相关文章
- flask + Python3 实现的的API自动化测试平台---- IAPTest接口测试平台,更名:FXTest 接受定制开发(java版开发完毕)
**背景: 1.平时测试接口,总是现写代码,对测试用例的管理,以及测试报告的管理持久化做的不够, 2.工作中移动端开发和后端开发总是不能并行进行,需要一个mock的依赖来让他 ...
- flask + Python3 实现的的API自动化测试平台---- IAPTest接口测试平台(总结感悟篇)
前言: 在前进中去发现自己的不足,在学习中去丰富自己的能力,在放弃时想想自己最初的目的,在困难面前想想怎么踏过去.在不断成长中去磨炼自己. 正文: 时间轴 flask + Python3 实现的的AP ...
- flask + Python3 实现的的API自动化测试平台---- IAPTest接口测试平台
**背景: 1.平时测试接口,总是现写代码,对测试用例的管理,以及测试报告的管理持久化做的不够, 2.工作中移动端开发和后端开发总是不能并行进行,需要一个mock的依赖来让他 ...
- django开发自动化测试平台简介
Django的优点 1:功能完善.要素齐全:自带大量常用工具和框架(比如分页,auth,权限管理), 适合快速开发企业级网站. 2:完善的文档:经过十多年的发展和完善,Django有广泛的实践案例和完 ...
- flask开发restful api
flask开发restful api 如果有几个原因可以让你爱上flask这个极其灵活的库,我想蓝图绝对应该算上一个,部署蓝图以后,你会发现整个程序结构非常清晰,模块之间相互不影响.蓝图对restfu ...
- Jenkins+Ant+Jmeter搭建持续集成的接口测试平台(转)
一.什么是接口测试? 接口测试是测试系统组件间接口的一种测试.接口测试主要用于检测外部系统与系统之间以及内部各个子系统之间的交互点.测试的重点是要检查数据的交换,传递和控制管理过程,以及系统间的相互逻 ...
- 【转】Jenkins+Ant+Jmeter搭建持续集成的接口测试平台
一.什么是接口测试? 接口测试是测试系统组件间接口的一种测试.接口测试主要用于检测外部系统与系统之间以及内部各个子系统之间的交互点.测试的重点是要检查数据的交换,传递和控制管理过程,以及系统间的相互逻 ...
- Linux下搭建HttpRunnerManager接口测试平台
前言 之前在学习HttpRunner时,我们都是把用例写在 YAML/JSON 中进行维护,使用起来也很方便.其实,现在有不少大佬都喜欢开发自动化测试平台,比如我们今天要搭建的HttpRunnerMa ...
- Flask开发系列之Flask+redis实现IP代理池
Flask开发系列之Flask+redis实现IP代理池 代理池的要求 多站抓取,异步检测:多站抓取:指的是我们需要从各大免费的ip代理网站,把他们公开的一些免费代理抓取下来:一步检测指的是:把这些代 ...
随机推荐
- 介绍一个免费的云开发工具:Cloud Shell
上周和一德国同事吹牛的时候,他说最近业余时间在玩一个东东,叫做Cloud Shell,Google出品.Jerry之前听说过国内的阿里云也提供过类似的解决方案,即在云端提供一个受限制的Linux环境并 ...
- 复盘一篇讲sklearn库学习文章(上)
认识 sklearn 官网地址: https://scikit-learn.gor/stable/ 从2007年发布以来, scikit-learn已成为重要的Python机器学习库, 简称sklea ...
- Java开发环境之JDK
查看更多Java开发环境配置,请点击<Java开发环境配置大全> 零章:JDK安装教程 1)下载JDK安装包 http://www.oracle.com/technetwork/java/ ...
- PHP提示 Notice: Undefined variable
PHP提示Notice: Undefined variable,意思是:你的程序中有未定义的变量 为什么在其他地方好好的程序,换个环境报这个Notice,因为php.ini提醒级别设置的问题 场景复原 ...
- MySQL/MariaDB数据库的查询缓存优化
MySQL/MariaDB数据库的查询缓存优化 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.MySQL架构 Connectors(MySQL对外提供的交互接口,API): ...
- python中str和byte的相互转化
在涉及到网络传输的时候,数据需要从str转换成btye才能进行传输. python byte 转 str , str 转 byte 其实很简单:原理图如下:在这里插入图片描述案例: a: str = ...
- python笔记35-装饰器
前言 python装饰器本质上就是一个函数,它可以让其他函数在不需要做任何代码变动的前提下增加额外的功能,装饰器的返回值也是一个函数对象. 很多python初学者学到面向对象类和方法是一道大坎,那么p ...
- HttpClient代码设置代理
由于对接faceBook接口,本地测试时候要设置代理才能调试. (http和https通用) public SSLContext createIgnoreVerifySSL() throws NoSu ...
- less-5
首先输入id=1和id=1’未报错,均显示You are in.....(如下图所示) 由上图可以看到,如果运行返回结果正确的时候只返回you are in...,不会返回数据库当中的信息了,所以我们 ...
- HBase学习笔记之BulkLoad
HBase学习之BulkLoad bulkload的学习以后再写文章. 参考资料: 1.https://blog.csdn.net/shixiaoguo90/article/details/78038 ...