V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · Jul 31, 2013 · 3128 views
    This topic created in 4666 days ago, the information mentioned may be changed or developed.
    开始是和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!"
    -----
    也是什么都没显示了。

    这个要怎么解决。
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   978 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 129ms · UTC 18:58 · PVG 02:58 · LAX 11:58 · JFK 14:58
    ♥ Do have faith in what you're doing.