Ask coding questions

← Back to all posts
Python Flask problem
isaiah08 (63)

If you go to /login, it gives an error. Why is it? It says that it has something to do with what it returns, but i still don't get the error. Thanks!

Answered by supcoolak (5) [earned 5 cycles]
View Answer
Comments
hotnewtop
supcoolak (5)

Can you let me know what the error is? Also, you left a method called post, but you haven't written anything inside it, making line 62:app.run('0.0.0.0') have an error called Indentation Error. If you want to work on that later, just make the code inside the repl pass, so the Python will just ignore it.

supcoolak (5)

@isaiah08 What do you mean did it? Was it the post method, or did you fix it already.

isaiah08 (63)

I just added pass so you can see the real error. @supcoolak

supcoolak (5)

@isaiah08 So, I found the problem! I forked your repl, so you can see that. First thing, the last return render template needs to be at second indentation level, meaning 4 spaces away from the most left of the line. Second thing, you don't actually have a .env file, meaning you have no SECRET_KEY. Just create a file called .env in the root (meaning not inside any dirs),and add a line of code that looks like this SECRET_KEY = ''. You must fill in the quotation marks with a string. NOTE: Anyone with this key has ROOT authority over your website.

isaiah08 (63)

Thanks! (I do have a .env file, it was just cut out when you forked it, as the whole point of .env files is secrecy :)@supcoolak