1

次の main.py ファイルがあります。

 import webapp2

 class MainPage(webapp2.RequestHandler):
 def get(self):
    if self.request.url.endswith('/'):
        path = '%sindex.html'%self.request.url
    else:
        path = '%s/index.html'%self.request.url

    self.redirect(path)


 app = webapp2.WSGIApplication([('/.*', MainPage)],
                                     debug=True)

app.yaml ファイル:

 application: gtryapp
 version: 1
 runtime: python27
 api_version: 1
 threadsafe: yes

ハンドラ:

  • url: /images/(. .(gif|png|jpg)) static_files: static/img/\1 アップロード: static/img/(. .(gif|png|jpg))

  • url: /css/(. .css) mime_type: text/css static_files: static/css/\1 アップロード: static/css/(. .css)

  • url: /js/(. .js) mime_type: text/javascript static_files: static/js/\1 アップロード: static/js/(. .js)

  • url: /(. .html) mime_type: text/html static_files: static/\1 アップロード: static/(. .html)

  • URL: .* スクリプト: main.app

ライブラリ:

  • 名前: webapp2 バージョン: "2.5.2"

これはディレクトリとファイルのリストです..では、なぜ404を取得するのですか??

ここに画像の説明を入力

私が書くなら

  • URL: /index.html

    mime_type: テキスト/html

    static_files: index.html

    アップロード: index.html

index.htmlページが表示されますが、画像はありません...これは画像の正規表現で何が起こっているのかかなり奇妙です?

4

1 に答える 1

4

よく私はこのように解決しました:

 application: gtryapp
 version: 1
 runtime: python27
 api_version: 1
 threadsafe: yes

handlers:

- url: /images
  static_dir: images

- url: /css
  mime_type: text/css
  static_dir: css

- url: /js
  mime_type: text/javascript
  static_dir: js

- url: /scripts/1.1
  mime_type: text/javascript
  static_dir: scripts/1.1

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

- url: /index.html
  mime_type: text/html
  static_files: index.html
  upload: index.html

- url: /ydc-contacts.html
  mime_type: text/html
  static_files: ydc-contacts.html
  upload: ydc-contacts.html

- url: /ydc-graphic.html
  mime_type: text/html
  static_files: ydc-graphic.html
  upload: ydc-graphic.html

- url: /ydc-graphic_design-bauer_bodoni.html
  mime_type: text/html
  static_files: ydc-graphic_design-bauer_bodoni.html
  upload: ydc-graphic_design-bauer_bodoni.html

- url: /ydc-graphic_design-humac.html
  mime_type: text/html
  static_files: ydc-graphic_design-humac.html
  upload: ydc-graphic_design-humac.html

- url: /ydc-graphic_design-olo.html
  mime_type: text/html
  static_files: ydc-graphic_design-olo.html
  upload: ydc-graphic_design-olo.html

- url: /ydc-graphic_design-software.html
  mime_type: text/html
  static_files: ydc-graphic_design-software.html
  upload: ydc-graphic_design-software.html

- url: /ydc-interior-anagnina.html
  mime_type: text/html
  static_files: ydc-interior-anagnina.html
  upload: ydc-interior-anagnina.html

- url: /ydc-interior-ied_meets_cinecitto.html
  mime_type: text/html
  static_files: ydc-interior-ied_meets_cinecitto.html
  upload: ydc-interior-ied_meets_cinecitto.html

- url: /ydc-interior.html
  mime_type: text/html
  static_files: ydc-interior.html
  upload: ydc-interior.html

- url: /ydc-interior_design-unofficial.html
  mime_type: text/html
  static_files: ydc-interior_design-unofficial.html
  upload: ydc-interior_design-unofficial.html

- url: /ydc-lighting-design.html
  mime_type: text/html
  static_files: ydc-lighting-design.html
  upload: ydc-lighting-design.html

- url: /ydc-lighting-pixelight.html
  mime_type: text/html
  static_files: ydc-lighting-pixelight.html
  upload: ydc-lighting-pixelight.html

- url: /ydc-lighting.html
  mime_type: text/html
  static_files: ydc-lighting.html
  upload: ydc-lighting.html

- url: /ydc-lighting_design_monochromenature.html
  mime_type: text/html
  static_files: ydc-lighting_design_monochromenature.html
  upload: ydc-lighting_design_monochromenature.html

- url: /ydc-manifesto.html
  mime_type: text/html
  static_files: ydc-manifesto.html
  upload: ydc-manifesto.html

- url: /ydc-members.html
  mime_type: text/html
  static_files: ydc-members.html
  upload: ydc-members.html

- url: /ydc-news.html
  mime_type: text/html
  static_files: ydc-news.html
  upload: ydc-news.html

- url: /ydc-page_under_construction.html
  mime_type: text/html
  static_files: ydc-page_under_construction.html
  upload: ydc-page_under_construction.html

- url: /ydc-pictures.html
  mime_type: text/html
  static_files: ydc-pictures.html
  upload: ydc-pictures.html

- url: /ydc-product.html
  mime_type: text/html
  static_files: ydc-product.html
  upload: ydc-product.html

- url: /ydc-product_design-ciabattalibro.html
  mime_type: text/html
  static_files: ydc-product_design-ciabattalibro.html
  upload: ydc-product_design-ciabattalibro.html

- url: /ydc-product_design-dog_s_tent.html
  mime_type: text/html
  static_files: ydc-product_design-dog_s_tent.html
  upload: ydc-product_design-dog_s_tent.html

- url: /ydc-product_design-kubo.html
  mime_type: text/html
  static_files: ydc-product_design-kubo.html
  upload: ydc-product_design-kubo.html

libraries:
- name: webapp2
  version: "2.5.2"

私はそれを一人でしなければならなかったので、私に答えてくれなかった皆さん、どうもありがとうございました:)私は今、自分自身にもっと満足しています:D

于 2013-04-01T00:59:44.923 に答える