測開之路六十二:接口測試平臺之公共的js、html、平臺入口

 

common.jscss

//定義後臺的host和端口
var host = 'http://192.168.xxx.1:8000'; //'http://127.0.0.1:8000';

//用於發送http請求
function http(url, data, method, success, fail)
{
//若是是get請求,直接傳參,若是是其餘請求,以json的格式傳參
var data = method == 'GET' ? data : JSON.stringify(data)
console.log("請求->" + url + " 使用方法->" + method)
console.log(data)
$.ajax({
type: method,
contentType: "application/json; charset=utf-8",
data: data,
url: url,
dataType: 'json',
success: success,
fail: fail
});
}

 

base.htmlhtml

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>

<!- 引入bootstrap相關的css,組件地址:https://v3.bootcss.com/ ->
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet">

<!- 預留給css的入口 ->
{% block style %}
{% endblock %}

<!- 引入jquery.min.js和bootstrap.min.js、common.js ->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="/static/common.js"></script>

<!- 預留給js的入口 ->
{% block script %}
{% endblock %}
</head>
<body>
<!- header的內容 ->
{% include 'header.html' %}

<!- 頁面內容 ->
{% block content %}
{% endblock %}

<!- footer的內容 ->
{% include 'footer.html' %}
</body>
</html>

 

footer.htmljquery

<footer>
<h1>這裏是footer</h1>
</footer>

header.htmlajax

<header>
<h1>這裏是header</h1>
</header>

 

test-platform.py(程序入口)json

from flask import Flask
from interface import interface

app = Flask(__name__)

# 註冊interface藍圖
app.register_blueprint(interface)

if __name__ == '__main__':
app.run(
host="0.0.0.0",
port=8000,
debug=True,
)
相關文章
相關標籤/搜索