Forums

I couldn,t figure out why my flask app is not working with database

I have created flask app. I want it to enter data into the database. A database is created with a password. I am using SQLalchemy and the server app is receiving the values from the form. The problem is after receiving values I could not enter them into the database and I am getting an error ("unhandled exception").

2020-06-30 13:44:43,678: Error running WSGI application 2020-06-30 13:44:43,695: jinja2.exceptions.TemplateNotFound: favicon.ico 2020-06-30 13:44:43,695: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/app.py", line 2464, in call 2020-06-30 13:44:43,695: return self.wsgi_app(environ, start_response) 2020-06-30 13:44:43,695: 2020-06-30 13:44:43,695: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app 2020-06-30 13:44:43,695: response = self.handle_exception(e) 2020-06-30 13:44:43,696: 2020-06-30 13:44:43,696: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception 2020-06-30 13:44:43,696: reraise(exc_type, exc_value, tb) 2020-06-30 13:44:43,696: 2020-06-30 13:44:43,696: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise 2020-06-30 13:44:43,696: raise value 2020-06-30 13:44:43,696: 2020-06-30 13:44:43,697: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app 2020-06-30 13:44:43,697: response = self.full_dispatch_request() 2020-06-30 13:44:43,697: 2020-06-30 13:44:43,697: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request 2020-06-30 13:44:43,697: rv = self.handle_user_exception(e) 2020-06-30 13:44:43,697: 2020-06-30 13:44:43,697: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception 2020-06-30 13:44:43,698: reraise(exc_type, exc_value, tb) 2020-06-30 13:44:43,698: 2020-06-30 13:44:43,698: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise 2020-06-30 13:44:43,698: raise value 2020-06-30 13:44:43,698: 2020-06-30 13:44:43,698: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request 2020-06-30 13:44:43,698: rv = self.dispatch_request() 2020-06-30 13:44:43,698: 2020-06-30 13:44:43,698: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request 2020-06-30 13:44:43,699: return self.view_functionsrule.endpoint 2020-06-30 13:44:43,699: 2020-06-30 13:44:43,699: File "/home/sankalanIN/sankalan/server.py", line 46, in html_page 2020-06-30 13:44:43,699: return render_template(page_name) 2020-06-30 13:44:43,699: 2020-06-30 13:44:43,699: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/templating.py", line 138, in render_template 2020-06-30 13:44:43,700: ctx.app.jinja_env.get_or_select_template(template_name_or_list), 2020-06-30 13:44:43,700: 2020-06-30 13:44:43,700: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/jinja2/environment.py", line 930, in get_or_select_template 2020-06-30 13:44:43,700: return self.get_template(template_name_or_list, parent, globals) 2020-06-30 13:44:43,700: 2020-06-30 13:44:43,700: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/jinja2/environment.py", line 883, in get_template 2020-06-30 13:44:43,700: return self._load_template(name, self.make_globals(globals)) 2020-06-30 13:44:43,700: 2020-06-30 13:44:43,700: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/jinja2/environment.py", line 857, in _load_template 2020-06-30 13:44:43,700: template = self.loader.load(self, name, globals) 2020-06-30 13:44:43,700: 2020-06-30 13:44:43,700: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/jinja2/loaders.py", line 115, in load 2020-06-30 13:44:43,701: source, filename, uptodate = self.get_source(environment, name) 2020-06-30 13:44:43,701: 2020-06-30 13:44:43,701: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/templating.py", line 60, in get_source 2020-06-30 13:44:43,701: return self._get_source_fast(environment, template) 2020-06-30 13:44:43,701: 2020-06-30 13:44:43,701: File "/home/sankalanIN/.virtualenvs/my-virtualenv/lib/python3.8/site-packages/flask/templating.py", line 89, in _get_source_fast 2020-06-30 13:44:43,701: raise TemplateNotFound(template)

You're trying to render a template that Flask cannot find. It looks like the variable page_name should is being used as a template name but, whatever the value of page_name is, there is not a template with that name.