报错该问题可能是页面 信息不同
这是报错信息
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
[2024-06-21 09:35:38,044] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\flask\app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\flask\app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\flask\app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\flask\app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\demo01\ap.py", line 5, in login
return render_template('login.html')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\flask\templating.py", line 149, in render_template
template = app.jinja_env.get_or_select_template(template_name_or_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\jinja2\environment.py", line 1084, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\jinja2\environment.py", line 1013, in get_template
return self._load_template(name, globals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\jinja2\environment.py", line 972, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\jinja2\loaders.py", line 126, in load
source, filename, uptodate = self.get_source(environment, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\flask\templating.py", line 65, in get_source
return self._get_source_fast(environment, template)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PyChArm\pythonProject\.venv\Lib\site-packages\flask\templating.py", line 99, in _get_source_fast
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: login.html
127.0.0.1 - - [21/Jun/2024 09:35:38] "GET / HTTP/1.1" 500 -
解决办法:
改上之后运行成功