how to fix it python flask we application error for internal server? : <p>I code in python using flask frame work to built  an application But it showing internal server error while redirecting to the next page.
the log in page contain the path which going to redirect to the next 
page.so how to fix that problem.
This is code for the app.py file.</p>

<pre><code>from flask import Flask, request, render_template

from flaskext.mysql import  MySQL

app = Flask(__name__)

mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = ''
app.config['MYSQL_DATABASE_DB'] = 'invertoryDb'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
MYSQL_DATABASE_SOCKET = '/tmp/mysql.sock'
mysql.init_app(app)



@app.route('/')
def my_form():
return render_template('loginPage.html')

@app.route('/login', methods=['POST'])
def Authenticate():

username = request.form['username']
password = request.form['password']
cursor = mysql.connect().cursor()
cursor.execute("SELECT * FROM user WHERE username='"+username+"' and password='"+password+"'")
data = cursor.fetchone()
if data is None:
    return "usernme and password is wrong"
else:
    return "logged in succesfully"

if __name__ == '__main__':
app.run()
</code></pre>

<p>this is the code for html file.</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Login page&lt;/title&gt;
&lt;style type="text/css"&gt;
    * {
    box-sizing: border-box;
    }

    *:focus {
    outline: none;
    }
    body {
    font-family: Arial;
    background-color: #3498DB;
    padding: 50px;
    }
    .login {
    margin: 20px auto;
    width: 300px;
    }
    .login-screen {
    background-color: #FFF;
    padding: 20px;
    border-radius: 5px
    }

    .app-title {
    text-align: center;
    color: #777;
    }

    .login-form {
    text-align: center;
    }
    .control-group {
    margin-bottom: 10px;
    }

    input {
    text-align: center;
    background-color: #ECF0F1;
    border: 2px solid transparent;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 200;
    padding: 10px 0;
    width: 250px;
    transition: border .5s;
    }

    input:focus {
    border: 2px solid #3498DB;
    box-shadow: none;
    }

    .btn {
    border: 2px solid transparent;
    background: #3498DB;
    color: #ffffff;
    font-size: 16px;
    line-height: 25px;
    padding: 10px 0;
    text-decoration: none;
    text-shadow: none;
    border-radius: 3px;
    box-shadow: none;
    transition: 0.25s;
    display: block;
    width: 250px;
    margin: 0 auto;
    }

    .btn:hover {
    background-color: #2980B9;
    }

    .login-link {
    font-size: 12px;
    color: #444;
    display: block;
    margin-top: 12px;
    }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action="/login" method="POST"&gt;
    &lt;div class="login"&gt;
        &lt;div class="login-screen"&gt;
            &lt;div class="app-title"&gt;
                &lt;h1&gt;Login&lt;/h1&gt;
            &lt;/div&gt;
            &lt;div class="login-form"&gt;
            &lt;div class="control-group"&gt;
                            &lt;input type="text" class="login-field" value="" placeholder="username" 
name="username"&gt;
            &lt;label class="login-field-icon fui-user" for="login-name"&gt;&lt;/label&gt;&lt;/div&gt;
            &lt;div class="control-group"&gt;
                            &lt;input type="password" class="login-field" value="" 
 placeholder="password" name="password"&gt;
            &lt;label class="login-field-icon fui-lock" for="login-pass"&gt;&lt;/label&gt;&lt;/div&gt;

                &lt;input type="submit" value="Log in" class="btn btn-primary btn-large btn-block"&gt;

            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>and this is the run console for the application.(error list)</p>

<pre><code>127.0.0.1 - - [03/Feb/2020 11:58:41] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [03/Feb/2020 11:58:41] "GET / HTTP/1.1" 200 -
[2020-02-03 11:58:54,752] ERROR in app: Exception on /login [POST]
Traceback (most recent call last):
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 2446, in 
wsgi_app
response = self.full_dispatch_request()
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1951, in 
full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1820, in ha 
ndle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\_compat.py", line 39, in 
reraise
raise value
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1949, in 
full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1935, in 
dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\OWNER\PycharmProjects\untitled\app.py", line 27, in Authenticate
cursor = mysql.connect().cursor()
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flaskext\mysql.py", line 54, in 
connect
if self.app.config['MYSQL_DATABASE_SOCKET']:
KeyError: 'MYSQL_DATABASE_SOCKET'
127.0.0.1 - - [03/Feb/2020 11:58:54] "POST /login HTTP/1.1" 500 -
</code></pre>
