簡體   English   中英

在 flask 應用程序上 - URI 以問號開頭並且不起作用

[英]On flask application - the URI start with a question mark and it doesn't work

這是我試圖讓它工作的請求:(返回 200 OK)

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM