python - Azure webapps 将反斜杠重写为斜杠

标签 python azure flask azure-web-app-service

我想知道如何解决这个特殊问题:

我有一个 Flask Web 应用程序,其中包含以下内容:

@app.route("/tags/<tagname>")
def tag(tagname):
    return lookup(tagname)

问题是源系统中的标签之一有反斜杠:abc\def

使用urlencode我得到url路径“/tags/tagname/abc%5Cdef”

在本地构建我的 docker 镜像,效果非常好,我可以返回 abc\def 的值。 但是,当我在 Azure Web 应用程序中使用此容器作为容器时,它会响应 404。

使用包罗万象的路线我发现
"/tags/tagname/abc%5Cdef" 在本地被翻译为 "/tags/tagname/abc\def",但 "/tags/tagname/abc/def"在 azure 中。当然,这会中断,因为未定义该路由并返回 404。

我现在不知道如何处理 Azure webapp 中的“\”。

最佳答案

尝试用几种不同的组合来转义

abc\\def
abc^\def
abc^^\def
abc^^^\def
abc&\def

关于python - Azure webapps 将反斜杠重写为斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58208199/

相关文章:

PayPal 的 Python 接口(interface) - urllib.urlencode 非 ASCII 字符失败

python - 如何让这个 Flask 应用程序更加 DRY(连接到许多 oauth API)?

python - MapReduce Amazon Python 获取输入文件的行号

Python 从文本文件中提取不同长度的值

azure - 如何修复由于 “No Plan” 错误而无法从镜像部署 VM 的 Azure 门户

database - Azure SQL 数据库 : Failover secondary DB is read-only

python - 如何为所有 Flask-SQLAlchemy 模型继承自定义构造函数

python - SQLAlchemy @property 在 Marshmallow 中使用 dump_only 导致 'Unknown Field' 错误

python - float 的日期时间不包括毫秒

powershell - 无法使用 Azure powershell 执行 pig 脚本