2013-06-04 44 views
0

我試圖從python遷移到2.7到2.5,但在對main.py和app.yaml文件進行必要的更改後,我的網站做了不行想要從2.5遷移到python 2.7,但做出更改後網站不會

請幫助...我應該做出什麼改變這些,以得到它的工作

main.py

import os 
from google.appengine.ext import webapp 

from google.appengine.ext.webapp import util 

from google.appengine.ext.webapp import template 

class MainHandler(webapp.RequestHandler): 
    def get (self, q): 
    if q is None: 
     q = 'index.html' 

    path = os.path.join (os.path.dirname (__file__), q) 
    self.response.headers ['Content-Type'] = 'text/html' 
    self.response.out.write (template.render (path, {})) 

def main(): 
    application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True) 
    util.run_wsgi_app (application) 

if __name__ == '__main__': 
    main() 

的app.yaml

application: cool-gadgets  
version: 1  
runtime: python  
api_version: 1  

handlers: 
- url: /robots.txt 
    static_files: static/robots.txt 
    upload: static/robots.txt 

- url: /favicon.ico 
    static_files: static/favicon.ico 
    upload: static/favicon.ico 

- url: /gadgets/disney.xml 
    static_files: gadgets/disney.xml 
    upload: gadgets/disney.xml 

- url: /gadgets/wwe.xml 
    static_files: gadgets/wwe.xml 
    upload: gadgets/wwe.xml 

- url: .* 
    script: main.py 

變化,我對此並遷移到2.7

Main.py

import os 
from google.appengine.ext import webapp 

from google.appengine.ext.webapp import util 

from google.appengine.ext.webapp import template 

class MainHandler(webapp.RequestHandler): 
    def get (self, q): 
    if q is None: 
     q = 'index.html' 

    path = os.path.join (os.path.dirname (__file__), q) 
    self.response.headers ['Content-Type'] = 'text/html' 
    self.response.out.write (template.render (path, {})) 


    application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True) 

的app.yaml

application: cool-gadgets  
version: 1  
runtime: python27  
api_version: 1  
threadsafe: true  

handlers: 
- url: /robots.txt 
    static_files: static/robots.txt 
    upload: static/robots.txt 

- url: /favicon.ico 
    static_files: static/favicon.ico 
    upload: static/favicon.ico 

- url: /gadgets/disney.xml 
    static_files: gadgets/disney.xml 
    upload: gadgets/disney.xml 

- url: /gadgets/wwe.xml 
    static_files: gadgets/wwe.xml 
    upload: gadgets/wwe.xml 

- url: .* 
    script: main.application 
+0

看到這個文檔:https://developers.google.com/appengine/docs/python/python25/migrate27 – voscausa

回答

2

請不要說 「不工作」。這沒有提供有用的信息。你應該說你看到了什麼,你得到什麼錯誤,等等。

在你的情況下,最有可能你有一個縮進錯誤:main.py末尾的application需要完全左移,因爲它是一個模塊級變量。

+0

喜丹尼爾 作出上述改變,我得到這個錯誤(錯誤500)後 「服務器遇到錯誤,無法完成您的請求 如果問題仍然存在,請報告您的問題,並提及此錯誤消息和導致它的查詢「 – user2451091

+0

謝謝丹尼爾 錯誤確實是由於縮進。 – user2451091