Your indentation of app.secret_key = "dd"
is wrong. It must be on the same level as the app.run
call.
Indentation is NOT OPTIONAL in Python - it's part of the syntax. You MUST indent blocks in a consistent way or your script won't run.
Python gives you very helpful error messages by the way - so please run your code in a terminal (cmd.exe on windows, any shell on other OSes) using python yourfile.py
. That way the terminal does not close when the script terminates and you actually see errors instead of having to ask here.
Also you handle SQL really wrong:
query = ("SELECT COUNT('email'), password FROM user WHERE email = '" + request.form['mail'] + "'")
cursor.execute(query)
That code has a gaping SQL injection hole. Do this instead:
query = "SELECT COUNT('email'), password FROM user WHERE email = %s"
cursor.execute(query, [request.form['mail']])
This way the database (or database api) will handle your arguments in a secure way.
Another thing: You should really use Jinja2 templates instead of creating an ugly mess of embedded HTML. It's an excellent template engine that's already a dependency of Flask anyway.