0

我是谷歌应用引擎的初学者。我的目标是将现有网页移植到 GAE。我遇到的困难集中在 .js 文件的位置。为了让它在我的本地机器上运行,我将 .js 文件放在一个静态目录中,并在 html 中引用,例如

<link href="/static/tblDz_Qs_clinical.js"....  

在我的本地机器上一切正常,但是当我部署时,我收到一条消息

 'we cannot locate the datafile
 http://dermdudes.appspot.com/static/tblDz_Qs_clinical.js'

这是main.py:

import os
import webapp2
import jinja2


template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape=False)

class Handler(webapp2.RequestHandler):
    def write(self, *a, **kw):
        self.response.out.write(*a, **kw)
    def render_str(self, template, **params):
        t = jinja_env.get_template(template)
        return t.render(params)
    def render(self, template, **kw):
        self.write(self.render_str(template, **kw))

class MainHandler(Handler):
    def get(self):
        self.render('DD_querydriven2.html')

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

这是 app.yaml:

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

handlers:
- url: /static
  static_dir: static

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.1"

- name: jinja2
  version: latest

这是触发消息的 html 中的引用:

<link href="/static/tblDz_Qs_clinical.js" type="application/json" rel="exhibit/data" />

如果我只能让 GAE 找到 .js 文件,那么一切都会完美。谢谢你的帮助。

4

1 回答 1

0

心理调试:区分大小写的文件名?,使文件名小写并将引用也更改为小写。

于 2012-06-04T06:11:58.427 回答