简体   繁体   English

在 flask 应用程序上 - URI 以问号开头并且不起作用

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

This is the request that I'm trying to make it work: (return 200 OK)这是我试图让它工作的请求:(返回 200 OK)

curl --cacert cert.pem -H "Content-Type: application/json" --data @./request.json https://localhost:8443/?timeout=30s

The problem with this request is the question mark at the beginning of the URI.此请求的问题在于 URI 开头的问号。 If I will write without it, like this: https://localhost:8443/timeout=30s It will work well .如果我没有它就写,像这样:https://localhost:8443/timeout=30s它会很好用。

This is my code:这是我的代码:

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")

for now, the request is returning:现在,请求正在返回:

 <.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'])

will not match with不匹配

https://localhost:8443/?timeout=30s

Your route would need to look something like你的路线需要看起来像

@app.route('/', methods=['GET', 'POST'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 以数字开头的集合规则不起作用 - Firebase rule for collection start with number doesn't work “CDK 部署”不启动 - "CDK deploy" doesn't start Google Cloud Translate API 密钥在使用 Android 应用程序限制时不起作用 - Google Cloud Translate API Key Doesn't Work When Using Android Application Restrictions Firebase @PropertyName 不起作用 - Firebase @PropertyName doesn't work URI 的目标不存在:'firebase_options.dart'。 尝试创建由 URI 引用的文件,或尝试对确实存在的文件使用 URI - Target of URI doesn't exist: 'firebase_options.dart'. Try creating the file referenced by the URI, or Try using a URI for a file that does exist 使用委托权限调用 MS Graph 不起作用,而应用程序权限可以 - Calling MS Graph with delegated privileges doesn't work while application privileges do flutterfire 配置在终端中不起作用 - flutterfire configure doesn't work in the terminal StorageReference getFile 无法正常工作 - StorageReference getFile doesn't work properly BigQuery 查询不适用于 UNNEST() - BigQuery query doesn't work with UNNEST() Azure function 运行时集成不起作用 - Azure function runtime integration doesn't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM