20

AppEngineアプリケーションを作成しました。今までのところ、提供できるHTMLファイルはごくわずかです。誰かがhttp://example.appengine.com/にアクセスするたびに、App Engineにindex.htmlファイルを提供させるにはどうすればよいですか?

現在、私のapp.yamlファイルは次のようになっています。

application: appname
version: 1
runtime: python
api_version: 1

handlers:

- url: /
  static_dir: static_files
4

5 に答える 5

40

これはあなたが必要とすることをするはずです:

https://gist.github.com/873098

説明:App Engine Pythonでは、正規表現をURLハンドラーとして使用しapp.yaml、すべてのURLを静的ファイルの階層にリダイレクトすることができます。

app.yaml

application: your-app-name-here
version: 1
runtime: python
api_version: 1

handlers:
- url: /(.*\.css)
  mime_type: text/css
  static_files: static/\1
  upload: static/(.*\.css)

- url: /(.*\.html)
  mime_type: text/html
  static_files: static/\1
  upload: static/(.*\.html)

- url: /(.*\.js)
  mime_type: text/javascript
  static_files: static/\1
  upload: static/(.*\.js)

- url: /(.*\.txt)
  mime_type: text/plain
  static_files: static/\1
  upload: static/(.*\.txt)

- url: /(.*\.xml)
  mime_type: application/xml
  static_files: static/\1
  upload: static/(.*\.xml)

# image files
- url: /(.*\.(bmp|gif|ico|jpeg|jpg|png))
  static_files: static/\1
  upload: static/(.*\.(bmp|gif|ico|jpeg|jpg|png))

# index files
- url: /(.+)/
  static_files: static/\1/index.html
  upload: static/(.+)/index.html

# redirect to 'url + /index.html' url.
- url: /(.+)
  static_files: static/redirector.html
  upload: static/redirector.html

# site root
- url: /
  static_files: static/index.html
  upload: static/index.html

.html認識されたタイプ( 、.pngなど)で終わらないURLへのリクエストを処理するには、または/それらのリクエストをリダイレクトして、そのディレクトリURL + /のforが提供されるようにする必要があります。index.html内でこれを行う方法がわからないapp.yamlため、javascriptリダイレクタを追加しました。これは、小さなPythonハンドラーを使用して実行することもできます。

redirector.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <script language="JavaScript">
      self.location=self.location + "/";
    </script>
  </head>
  <body>
  </body>
</html>
于 2011-04-10T02:47:14.270 に答える
9

/マップしようとしている場合index.html

handlers:
- url: /
  upload: folderpath/index.html
  static_files: folderpath/index.html

パス上で一致し、url:正規表現をサポートします。

- url: /images
  static_dir: static_files/images

したがって、画像ファイルがstatic_files/images/picture.jpg使用時に保存されている場合は、次のようになります。

<img src="/images/picture.jpg" />
于 2011-04-10T01:36:22.960 に答える
9

(app.yaml)を使用して実行できます:

handlers:
- url: /appurl
  script: myapp.app

- url: /(.+)
  static_files: staticdir/\1
  upload: staticdir/(.*)

- url: /
  static_files: staticdir/index.html
  upload: staticdir/index.html
于 2013-11-11T17:44:00.813 に答える
1

WEB-INF / web.xmlに次のように入力します:

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
于 2011-04-10T00:57:29.870 に答える
1

Jekyllによって生成されたサイトを機能させる方法についてはapp.yamlを次に示します。

runtime: python27
api_version: 1
threadsafe: true


handlers:
- url: /
  static_files: _site/index.html
  upload: _site/index.html

- url: /assets
  static_dir: _site/assets



  # index files
- url: /(.+)/
  static_files: _site/\1/index.html
  upload: _site/(.+)/index.html

- url: /(.*)
  static_files: _site/\1
  upload: _site/(.*)

- url: /.*
  static_dir: _site
于 2018-05-08T19:21:30.003 に答える