使用Google App Engine我希望學習一些關於這個問題的基礎知識。我希望打開一個index.html頁面,當打開應用程序時,該頁面將放置在一個文件夾中。使用Google App Engine如何打開html頁面?
我生成使用新應用「谷歌應用程序引擎啓動」
我稍微修改了的app.yaml,現在看起來像下面...
application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /templates
static_dir: templates
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
我也有一個加了名爲「模板」的目錄。
在目錄中,我放置了一個名爲'index.html'的文件。
<html>
<header><title>This is title</title></header>
<body>
Hello world cls
</body>
</html>
我main.py沒有被修改,所以它看起來像
#!/usr/bin/env python
#
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello world!')
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
任何想法什麼我需要做什麼或改變,以找到成功?
問候,
克里斯
> 我的代碼已經在一個大的方式改變了,因爲一個共同的從格溫
mment我現在已經從鏈路標準的Django模板代碼(https://console.developers.google.com/start/appengine) 格溫最終index.html文件會比靜態頁面的東西多一點所以你描述的直接URL不起作用。你雖然教我,隨着我的進步,它會派上用場。我想在一些高分子代碼帶來一旦我得到的基本想通了這裏......
所以,如果有人能幫助我從一個「模板」文件夾中使用索引養活一個Hello World從Google Developers Console生成的標準django代碼集的.html頁面,那麼您的答案將非常感謝。
問候,
克里斯
如果你只是想提供靜態html頁面,那麼你根本不需要python,如果你導航到/templates/index.html它應該加載。但是,如果您嘗試提供動態內容,則需要python,並且最好使用某種模板框架,如jinja2。這是一個工作示例https://developers.google.com/appengine/docs/python/gettingstartedpython27/templates – 2014-08-27 15:26:32
@GwynHowell您的評論讓我(https://console.developers.google.com/start/appengine)和從那裏我下載了django代碼,所以我原來的代碼不再有效。這仍然不是我所需要的,但我認爲你讓我更接近 – 2014-08-27 18:01:31