1

新しい GAE プロジェクトをセットアップしていますが、サブディレクトリ内のスクリプトを動作させることができません。

編集: 私が行った場合localhost:8080/testing_desc.html、エラーはありません。空白のページです (ビューソースも空白です)。ルート ディレクトリのスクリプトは正常に動作します。__init__.pyルートとサブディレクトリの両方にa があります。

Python スクリプトの例 ("/testing/testing_desc.py"):

import webapp2 as webapp

class DescTstPage(webapp.RequestHandler):
    def get(self):
        html = 'This should work.'
        self.response.out.write(html)

app = webapp.WSGIApplication([('/.*', DescTstPage)], debug=True)

app.yaml:

application: blah
version: blah
runtime: python27
api_version: 1

default_expiration: "5d 12h"

threadsafe: false

libraries:
- name: webapp2
  version: latest


handlers:
- url: /                  <-- This one works
  script: main.app
- url: /index.html        <-- This does NOT work (??)
  script: main.app
- url: /(.*?)_desc.html   <-- Also does NOT work
  script: \1/\1_desc.app
#file not found
- url: /.*
  script: file_not_found.app

より単純なバージョンの yaml も試しました。

-url: /testing_desc.html
 script: /testing/testing_desc.app
4

4 に答える 4

0

スクリプトをサブディレクトリで機能させるために、 and を次のように変更しapp.yamlまし/testing/testing_desc.pyた。

app.yaml:

- url: /testing.html
  script: testing/testing_desc.py

/testing/testing_desc.py:

app = webapp.WSGIApplication([('/.*', DescTstPage),], debug=True)

def main():
    run_wsgi_app(app)

if __name__ == '__main__':
    main()

ATM sub-dir でルーティングを機能させる方法がわからないので、これを使用します。

于 2013-11-06T16:04:04.983 に答える
0

答えはここにあります: gaeのサブフォルダーでスクリプトを使用するにはどうすればよいですか?

明示的には述べられていませんが、回答では、呼び出しで に変更/foo/する必要があります。これは にマップされます。にマップする場合は、呼び出しでに変更する必要があり、app.yaml の URL ハンドラーを次のように変更する必要があります。/fooWSGIApplicationwww.bar.com/foowww.bar.com/foo.html/foo/foo.*WSGIApplication- url: /foo\.html

于 2013-11-06T19:58:14.287 に答える