Python:页面从不加载,没有语法错误

Python:页面从不加载,没有语法错误,python,html,jinja2,app.yaml,Python,Html,Jinja2,App.yaml,我使用Jinja2用Python创建了一个简单的网页。当我在浏览器中运行代码时,页面只显示加载,但从不加载。我已经安装了jinja2,我的front.html文件位于templates文件夹中 我的日志显示: WARNING 2014-02-21 14:17:49,151 api_server.py:341] Could not initialize images API; you are likely missing the Python "PIL" module. INFO 201

我使用Jinja2用Python创建了一个简单的网页。当我在浏览器中运行代码时,页面只显示加载,但从不加载。我已经安装了jinja2,我的front.html文件位于templates文件夹中

我的日志显示:

WARNING  2014-02-21 14:17:49,151 api_server.py:341] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO     2014-02-21 14:17:49,164 api_server.py:138] Starting API server at: http://localhost:49824
INFO     2014-02-21 14:17:49,168 dispatcher.py:171] Starting module "default" running at: http://localhost:11001
INFO     2014-02-21 14:17:49,171 admin_server.py:117] Starting admin server at: http://localhost:8004
My app.yaml文件:

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

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: .*
  script: asciichan.app
- url: /templates
  script: front.html

libraries:
- name: webapp2
  version: "2.5.2"
- name: jinja2
  version: latest
我的Python文件:

import os
import webapp2
import jinja2

from google.appengine.ext import db

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

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 MainPage(Handler):
    def render_front(self, title="", art="", error=""):
        self.render("front.html", title=title, art=art, error=error)

    def get(self):
        self.render_front()

    def post(self):
        title = self.request.get("title")
        art = self.request.get("art")

        if title and art:
            self.write("thanks!")
        else:
            error = "we need both a title and some artwork!"
            self.render_front(title, art, error)

app = webapp2.WSGIApplication([('/', MainPage)], debug = True)
My front.html文件:

<!DOCTYPE html>

<html>
    <head>
        <title>/ascii/</title>
    </head>

    <body>
        <h1>/ascii/</h1>

        <form method = "post">
            <label>
                <div>title</div>
                <input type="text" name="title" value="{{title}}">
            </label>

            <label>
                <div>art</div>
                <textarea name="art">{{art}}</textarea>
            </label>

            <div class="error">{{error}}</div>
            <input type="submit">
        </form>

    </body>
</html>

/ascii码/
/ascii码/
标题
艺术
{{艺术}
{{error}}

抱歉,时间太长了,但我不知道问题出在哪里。任何帮助都将不胜感激

它表示您的默认服务器位于:

http://localhost:11001

INFO     2014-02-21 14:17:49,168 dispatcher.py:171] Starting module "default" running  at: http://localhost:11001 
然而,我们将:

http://localhost:11001/ 
将要求您在asciichan.py文件中具有def索引。在浏览器中尝试以下操作:

http://localhost:11001/MainPage 

希望这有帮助

你打算使用什么url?只是从我的本地主机运行,还没有特定的url。我还有其他项目(我使用的是Google App Engine),它们都会在日志中给我相同的PIL模块警告,但这些工作正常。只是这个项目不会加载。你要使用哪个url端口?试试这个
http://localhost:8080/