[英]On flask application - the URI start with a question mark and it doesn't work
curl --cacert cert.pem -H "Content-Type: application/json" --data @./request.json https://localhost:8443/?timeout=30s
此請求的問題在於 URI 開頭的問號。 如果我沒有它就寫,像這樣:https://localhost:8443/timeout=30s它會很好用。
這是我的代碼:
from flask import Flask, request
import logging
import os
app = Flask(__name__)
@app.route('/<path:str>', methods=['GET', 'POST'])
def index(str):
content = request.get_json()
response = {
"apiVersion": "admission.k8s.io/v1",
"kind": "AdmissionReview",
"response": {
"uid": content["request"]["uid"],
"allowed": True
}}
return response
if __name__ == '__main__':
cert_path = "/home/docker"
app.run(ssl_context=(os.path.join(cert_path, 'cert.pem'), os.path.join(cert_path, 'key.pem')), debug=True, port=8443, host="0.0.0.0")
<.DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>404 Not Found</title> <h1>Not Found</h1> <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
@app.route('/<path:str>', methods=['GET', 'POST'])
不匹配
https://localhost:8443/?timeout=30s
你的路線需要看起來像
@app.route('/', methods=['GET', 'POST'])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.