2013-03-30 62 views
1

我有以下main.py文件:谷歌應用程序引擎GET /index.html HTTP/1.1" 404 -

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 上傳時間:靜態/ IMG /(。(GIF | PNG | JPG))

  • 網址:。。/ CSS /(的.css) MIME_TYPE:文/ CSS static_files:靜態/ CSS/\ 1 上傳:靜態/ CSS /(。的CSS)

  • 網址:/ JS /(的.js) MIME_TYPE:文/ JavaScript的 static_files:靜態/ JS/\ 1 上傳:靜態/ JS /(的.js)

  • 網址:/(的.html) MIME_TYPE:text/html的 static_files:靜態/ \ 1 上傳:靜態/(。的.html)

  • 網址:* 腳本:main.app

庫:

  • 名稱:webapp2的 版本: 「2.5.2」

這是目錄和文件列表..所以爲什麼我得到404?

enter image description here

如果我寫

  • 網址:/index.html

    MIME_TYPE:text/html的

    static_files:index.html的

    上傳:指數html的

它告訴我的index.html頁,但沒有圖像...這是非常奇怪的是與圖像的正則表達式怎麼回事?

+0

一個簡單的實驗將註釋掉'。*。html' –

+0

的處理程序聲明似乎是因爲/index.html沒有路徑映射。 – marcadian

+0

嘗試使用/.*\.html處理程序的正則表達式 – ericmux

回答

2

以及我解決這樣的:

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" 

非常感謝你給大家不回答我,因爲我不得不做出獨自:) IM更滿意現在自己的:d