#๐Ÿ”’ Why isn't my method in Flask working properly?

50 messages ยท Page 1 of 1 (latest)

small ridgeBOT
#

Please react with โœ… to upload your file(s) to our paste bin, which is more accessible for some users.

#

@wild fjord

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

wild fjord
#

I didn't delete the explanation I wrote, idk why it's showing that

#

I'll type it again

#

The second method in the "app.py" file takes some input, after which it's supposed to run the third method if the method is 'POST', instead it says 'The method is not allowed for the requested URL.'

faint surge
#

please use the pastebin, it helps so much with reading your code

#

you can use multiple files

wild fjord
latent lintel
small ridgeBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

faint surge
wild fjord
#

Is this link working?

dim vault
#

yeah it does

#

I see the issue

#

your input name in the html form should match the key used in your function

#
<input type="text" name="un" placeholder="Username"><br/>
``` as opposed to ```py
username = request.form["username"]
#

@wild fjord

#

Try this for username and password

wild fjord
#

@dim vault I didn't get what you mean

dim vault
#

change this line

username = request.form["username"]
``` to ```py
username = request.form["un"]
wild fjord
#

if you mean change

username = request.form["username"]

to

username = request.form["un"]

I did that, no change as far as I can see

dim vault
#

for the password too

#

does your code work now?

wild fjord
#

tried it, still doesn't work

#

Have you tried running my code on your end?

dim vault
#

I think this line needs to be rechecked

redirect(url_for("user", usr=username))
dim vault
#

So far I only did static analysis

wild fjord
#

I think I found out what the problem is

#

<form action="/hehe" method="POST">

#

"hehe" doesn't exist

dim vault
#

It works now?

wild fjord
#

It works now

#

yay

dim vault
#

I will check that the next time I help someone, noted

#

My vscode is so slow

wild fjord
#

I use the same

dim vault
#

any time

dim vault
wild fjord
#

ah, i see

dim vault
#

Now you know what are the action in form and name in inputs are for

wild fjord
#

yup

#

Thanks @dim vault , @faint surge and @latent lintel!

dim vault
#

You're welcome

wild fjord
#

!close

small ridgeBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.