problem description
I am trying to make the flask running in the virtual environment load the html file into the local port, I compared the sample code (this example comes from CS50) but did not find the error; I also renamed the function name according to the information found in the network search, but still reported an error, I very much hope that someone can help me give some other ideas.
this is my error message
/ / Please paste the code text below (do not replace the code with pictures)
Traceback (most recent call last):
File "c:\users\thinkpad\myproject\venv\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "c:\users\thinkpad\myproject\venv\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\users\thinkpad\myproject\venv\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\users\thinkpad\myproject\venv\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "c:\users\thinkpad\myproject\venv\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "c:\users\thinkpad\myproject\venv\lib\site-packages\flask\app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\Thinkpad\myproject\hello.py", line 6, in index
return render_template("myindex.html")
AttributeError: "function" object has no attribute "html"
127.0.0.1 - - [22/Oct/2018 20:44:55] "GET / HTTP/1.1" 500 -
this is my hello.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template("myindex.html")
this is my myindex.html, under the templates folder
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
I am running set FLASK_APP=hello.py, flask run, the path where hello.py is located in a virtual environment.