Non-UTF-8 Code Error while starting a flask application with debug mode

I am running a simple bulb application. The python file is similar to the following.

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))

And I set the environment variables as following.

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

But I got an error like the following.

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
+4
source share

Source: https://habr.com/ru/post/1673989/


All Articles