V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
FixMe
V2EX  ›  Python

新手求问,gunicorn 的输出问题

  •  
  •   FixMe · 2013-07-31 18:58:48 +08:00 · 2509 次点击
    这是一个创建于 3915 天前的主题,其中的信息可能已经有所发展或是发生改变。
    开始是和Jinja2 这个模板一起测试的,在浏览器里什么没有显示。
    ----- myapp.py
    # -*- coding: utf-8 -*-
    from jinja2 import Template

    def app(environ, start_response):
    template = Template('Hello {{ name }}!')
    start_response("200 OK", [
    ("Content-Type", "text/plain")
    ])
    return template.render(name='John Doe')
    ----------------

    在jinja2那里看到,所有的输出都是UTF-8的。
    所以再做了下面两个对比的测试。

    ---- myapp1.py
    def app(environ, start_response):
    return "Hello!"
    -----
    可以看到看到 Hello!

    ---- myapp2.py
    def app(environ, start_response):
    return u"Hello!"
    -----
    也是什么都没显示了。

    这个要怎么解决。
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2839 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 14:21 · PVG 22:21 · LAX 07:21 · JFK 10:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.