目标:
使用 swagger、python、mongoDB 测试所有 HTTP 请求。我正在尝试使用 URL(在 swagger 中定义)点击 python 函数(包含'home.html'),但得到原始 HTML 作为响应。计划是通过 GET 请求命中它,然后在使用 HTML 表单后测试其他 HTTP 请求。
我试过使用烧瓶'@app.route('/home')',它正在工作,但我不想使用它。
招摇.yml ----
paths:
/app/{home}:
get:
summary: "fetching data from mongoDB"
description: "description GET"
operationId: "_read_app"
consumes:
- "application/json"
- "application/text"
produces:
- "application/json"
- "application/xml"
- "application/html"
parameters:
- name: "home"
in: "path"
description: "Updated name of the person"
required: True
type: "string"
测试.py ----
""def _read_app(home):
return render_template('home.html', home=home)"""
html响应----
"<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n <meta charset=\"UTF-8\">\n <title> Homepage </title>\n</head>\n\n<body>\n\n<h1>Extended \"Base Template\" from base</h1>\n\n\n\n\n\n<h2>Inherited content from base to here !</h2>\n\n\n\n<h1>Welcome ,home page!</h1>\n<!--<h2>This is .</h2>-->\n\n\n<h2>This is a else block</h2>\n\n\n\n\n\n\n\n<img src=\"/static/images/panda.jpg\">\n<h1>included from \"include.html\" to here</h1>\n<h2>name is: </h2>\n\n\n\n</body>\n\n</html>"