Lesson 2 app not working locally

Hi. Could anyone help me fix the lesson 2 app, which is not working locally?

I’ve successfully deployed it on render. However I get the following issue when I try to run it locally.

I run python app/server.py serve
It appears to run the server correctly, with the final line in the terminal being:

INFO: Uvicorn running on http://0.0.0.0:5042 (Press CTRL+C to quit)

I then load http://localhost:5042/ in my browser and the browser shows ‘Internal Server Error’. The command line shows:

ERROR: Exception in ASGI application
Traceback (most recent call last):
File “C:\Users\Jack\Anaconda3\lib\site-packages\uvicorn\protocols\http\h11_impl.py”, line 369, in run_asgi
result = await app(self.scope, self.receive, self.send)
File “C:\Users\Jack\Anaconda3\lib\site-packages\uvicorn\middleware\asgi2.py”, line 7, in call
await instance(receive, send)
File “C:\Users\Jack\Anaconda3\lib\site-packages\starlette\middleware\errors.py”, line 125, in asgi
raise exc from None
File “C:\Users\Jack\Anaconda3\lib\site-packages\starlette\middleware\errors.py”, line 103, in asgi
await asgi(receive, _send)
File “C:\Users\Jack\Anaconda3\lib\site-packages\starlette\exceptions.py”, line 74, in app
raise exc from None
File “C:\Users\Jack\Anaconda3\lib\site-packages\starlette\exceptions.py”, line 63, in app
await instance(receive, sender)
File “C:\Users\Jack\Anaconda3\lib\site-packages\starlette\routing.py”, line 43, in awaitable
response = await run_in_threadpool(func, request)
File “C:\Users\Jack\Anaconda3\lib\site-packages\starlette\concurrency.py”, line 24, in run_in_threadpool
return await loop.run_in_executor(None, func, *args)
File “C:\Users\Jack\Anaconda3\lib\concurrent\futures\thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “app/server.py”, line 50, in index
return HTMLResponse(html.open().read())
File “C:\Users\Jack\Anaconda3\lib\encodings\cp1252.py”, line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x90 in position 259: character maps to

I am getting the same error, were you able to solve it?

same problem here

I found the solution for it. in the server.py change
return HTMLResponse(html_file.open().read())
with this:
return HTMLResponse(html_file.open(encoding=“utf-8”).read())