更新: より単純な python スクリプトに変更
ほとんど静的な Google App Engine でホストされている Web サイトがあります。これで、サーバー内の特定のフォルダーの下にあるファイルのリストを返す Python スクリプトができました。JavaScript でこのファイルのリストが必要です。
helloworld.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, webapp2 World!')
app = webapp2.WSGIApplication([('/GetImages', MainPage)], debug=True)
<script>
jQueryを使用してindex.htmlのタグでこのPythonスクリプトを呼び出しています
$.ajax({
type: "GET",
url: "/GetImages",
dataType: "text",
success: function(data) {
alert(data);
}
});
私の app.yaml には、このハンドラーが定義されており、静的ファイル用の他のハンドラーも定義されています
- url: /GetImages
script: helloworld.app
Google App Engine ランチャーを起動しましたが、localhost:8080/GetImages で自分のサイトを開くと、hello world 文字列が表示されません。
問題は app.yaml にあると思います。ハンドラに以下を追加すると、サーバー エラーが発生します。これは許されませんか?
- url: /static
static_dir: static