Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1214

Flask: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

$
0
0

I am working on a python project using the flask module. It's not the first time i've used it but i am still very much a novice. While i was setting up a very simple file this error came up: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byteThis is my app.py file:

from flask import Flask,render_templateapp = Flask(__name__, template_folder='templates')@app.route("/")def index():    return render_template("index.html")if __name__ == '__main__':    app.run(host="0.0.0.0", debug=True)

and this is my index.html file:

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Flask app</title></head><body><h1>Hello world</h1></body></html>

The problem only occurs when i try to render the template as if i take out the render template and substitute it with somthing like return "Hello world"i don't have any problems and by going to the site i see Hello world.

What is the cause of the error? Python's version is 3.10 and i am on a linux pc

I've tried to redo this code on my windows pc with python 3.9.13 i have no problem, while by using my linux computer with python 3.10 i keep encountering it.


Viewing all articles
Browse latest Browse all 1214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>