添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here .

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Hi, everybody! I have a problem, when I try to launch this code locally, using PowerShell on Windows 7:

from flask import Flask
app = Flask(__name__)
app.route('/')
app.route('/<name>')
def index(name="Treehouse"):
    return "Hello from {}".format(name)
app.run(debug=True, port=8000, host='127.0.0.1') # I changed host, so I can get to the page using my browser.

and when I run this script, it throws an exception:

  File "c:\python35\Lib\socket.py", line 658, in getfqdn
    hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 2: invalid continuation byte

Is it because of some problem with utf to convert some symbols in uncode?

Not sure about the byte decode issue, but there is another issue with your code.

The app.route decorators need to be prefixed with an at sign @

@app.route('/')
@app.route('/<name>')
def index(name="Treehouse"):
    return "Hello from {}".format(name)

Post back if that's not the issue.