Ask coding questions

← Back to all posts
How can I make flask and replit db compatible
h
okalisl

I have been working on a login system and have recently been having issues with making the db work without having an error. What am I doing wrong? (lines 10-21 with the error)

Voters
okalisl
Comments
hotnewtop
SixBeeps

Looks like you've set the /signup route to be for GETting, but at the same time, you're trying to get some form data. This is not possible, since form data must go through a POST request.

Also, you don't have a form set up in your Sign Up page. To send data to your server, you actually need to declare a <form> tag with <input>s. Then, you'll submit the data to one of your server's endpoints, preferably separate from the endpoint that's serving the sign up page itself.

okalisl

I changed it @SixBeeps. Is this right?

SixBeeps

@okalisl Ummm, there's still no valid <form>, nor is there a new endpoint to receive the form data.

okalisl

How can I make this happen @SixBeeps?

SixBeeps

@okalisl I suggest you learn what an HTML Form is and the basics of HTTP.

You've already got one of your endpoints set explicitly to GET, but you'll need another one set to POST only. Once you have a POST endpoint, direct the form on the signup page with the action attribute to it. Then, you can handle the form data (i.e. do stuff with request.form) in there.

CosmicBear

Line 10 should be @app.route('/signup',methods=["GET","POST"])
Right now, it is only accepting GET requests but you need to be able to handle both GET & POST as you want to return templates.