【问题标题】:Python AppEngine - How to pass query strings in app.yamlPython AppEngine - 如何在 app.yaml 中传递查询字符串
【发布时间】:2016-08-11 19:40:10
【问题描述】:

我正在尝试根据移动平台设置不同的文件夹,但我不知道该怎么做。

这里有一些代码:

App.yaml

- url: /winners
  secure: always
  static_files: static_files/winners.json
  upload: static_files/winners.json
  http_headers:
    Content-Type: application/json; charset=latin-1

这很好,但是当我像这样设置查询字符串时:

- url: /winners?platform=android
  secure: always
  static_files: static_files/winners.json
  upload: static_files/winners.json
  http_headers:
    Content-Type: application/json; charset=latin-1

没有!

我基本上是想根据每个平台发送不同的资源,这个可以吗?

谢谢:)

ps:类似的问题对我想要实现的目标说“不”Define query param in app.yaml in Google Appengine

【问题讨论】:

    标签: python google-app-engine yaml


    【解决方案1】:

    作为您引用的问题的答案,通过app.yaml 路由时将忽略查询参数。但是可以根据每个平台提供不同的资源,只能使用其他机制。

    一种方法是在 URL 中编码平台,但不是作为查询参数,例如 /winners/android,通过此 app.yaml 路由处理:

    - url: /winners/(.*)$
      secure: always
      static_files: static_files/\1/winners.json
      upload: static_files/\1/winners.json
      http_headers:
        Content-Type: application/json; charset=latin-1
    

    这将提供存储为static_files/android/winners.json的文件

    更多详情请见Static file pattern handlers

    【讨论】:

    • 感谢您的回答,我检查了另一个与我相关的问题,我认为您所说的是要走的路。 :)
    猜你喜欢
    • 2012-07-03
    • 2020-11-29
    • 2013-02-21
    • 1970-01-01
    • 2016-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多