【问题标题】:How should I write my Google App Engine app.yaml file?我应该如何编写我的 Google App Engine app.yaml 文件?
【发布时间】:2011-05-18 12:18:27
【问题描述】:

我注册了一个 Google App Engine 应用,我有一些文件如下:

/index.html

/css/index.css

/js/index.js

/feedbacks/index.html

/feedbacks/css/index.css

/feedbacks/js/index.js

app.yaml文件应该怎么写?

谢谢!

【问题讨论】:

    标签: google-app-engine yaml


    【解决方案1】:
    application: appname
    version: 1
    runtime: python
    api_version: 1
    
    handlers:
    
    -   url: /favicon.ico
        static_files: img/favicon.ico
        upload: img/favicon.ico
        mime_type: image/x-icon
    
    -   url: /css  #your css folder
        static_dir: css 
    
    -   url: /scripts #your javascript folder
        static_dir: scripts
    
    
    -   url: /img #your image folder
        static_dir: img
    
    -   url: /.*
        script: your_script.py
    

    【讨论】:

      【解决方案2】:

      将您的前 3 个文件放入名为“static”的文件夹中

      handlers:
      -   url: /feedbacks/
          static_dir: feedbacks
      
      -   url: /css/
          static_dir: static
      
      -   url: /js/
          static_dir: static
      
      -   url: /.*
          script: main.py
      

      在您的 ma​​in.py

      class IndexHandler(webapp.RequestHandler):
          def get(self):
              self.redirect('static/index.html')
      
      
      def main():
          application = webapp.WSGIApplication([
                  ('/index.html', IndexHandler),
              ], debug=True)
          run_wsgi_app(application)
      

      这样写不好, 但这会解决你的问题。

      【讨论】:

      • 感谢您的回复!大熊。
      猜你喜欢
      • 2011-07-01
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 2020-03-19
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      • 2014-08-12
      相关资源
      最近更新 更多