非UTF-8代码使用调试模式运行烧瓶应用程序时出错

时间:2017-04-04 13:11:06

标签: python flask

我正在运行简单的烧瓶应用程序。 python文件如下所示。

import os
from flask import Flask, jsonify

app = Flask(__name__)

@app.route('/')
def Welcome():
    return app.send_static_file('index.html')

@app.route('/myapp')
def WelcomeToMyapp():
    return 'Welcome again to my app running on Bluemix!'

@app.route('/api/people')
def GetPeople():
    list = [
        {'name': 'John', 'age': 28},
        {'name': 'Bill', 'val': 26}
    ]
    return jsonify(results=list)

@app.route('/api/people/<name>')
def SayHello(name):
    message = {
        'message': 'Hello ' + name
    }
    return jsonify(results=message)

port = os.getenv('PORT', '5000')
if __name__ == "__main__":
    app.run(host='0.0.0.0', port=int(port))

我将环境变量设置如下。

set FLASK_DEBUG=1
set FLASK_APP=welcome.py
flask run

但是我得到了如下错误。

D:\workspace\github\pytyon-flask-sample>flask run
 * Serving Flask app "welcome"
 * Forcing debug mode on
 * Restarting with stat
  File "D:\ide\python-3.5\Scripts\flask.exe", line 1
SyntaxError: Non-UTF-8 code starting with '\x90' in file D:\ide\python-3.5\Scripts\flask.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

0 个答案:

没有答案