Forums

Internal Server Error

I got Error: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Using Code:

from flask import Flask,render_template,url_for,request,session,redirect
from forms import RegistrationForm,LoginForm
import MySQLdb
app=Flask(__name__)

app.config['SECRET_KEY']='secretkey'
# app.config['MYSQL_HOST']='TanmayMudgal.mysql.pythonanywhere-services.com'
# app.config['MYSQL_USER']='TanmayMudgal'
# app.config['MYSQL_PASSWORD']='password'
# app.config['MYSQL_DB']='Cred'
# app.config['MYSQL_CURSORCLASS']='DictCursor'
mysql=MySQLdb.connect(host='TanmayMudgal.mysql.pythonanywhere-services.com',user='username',password='password')

@app.route('/register',methods=['GET','POST'])
def register():
    if request.method=='POST':
        username=request.form['username']
        email=request.form['email']
        password=request.form['password'].encode()

        cur=mysql.cursor()
        cur.execute("insert into user values('"+str(username)+"','"+str(email)+"','"+str(password)+"')")
        mysql.connection.commit()
        session['username']=username
        session['email']=email
        return redirect(url_for('home'))

    else:
        form=RegistrationForm()
        return render_template('register.html',title='Register',form=form)

How should I Solve it Please Help Me Thanks!

[edit by admin: formatting]

Take a look at the error log for your website -- there's a link on the "Web" page, and the most recent error will be at the bottom of the file. The message you see there should help you work out what is going wrong.

Nothing in my error log

What does not work for you?