Unable To Access Page (Flask)

I am unable to access the page 400 Bad Request (redcoder.repl.co).
Link to repl: https://replit.com/@RedCoder/New-Star-Cards?v=1

1 Like

Do you get any errors on the console when accessing the owner-dashboard route?
Maybe this will help get to the problem.

1 Like

No. I do not get any errors.

1 Like

Moved this to Python since it seems like a Flask server-end problem.

1 Like

@SnakeByte It is, good idea. Any ideas on the error? It gives a 400 error when I try to load the page.

I’m not sure, I don’t know much Flask.
Let me see…

@SnakeByte Any luck figuring it out?

it works in the replit.com embed…

NVM its the homepage

2 Likes

it tries to access the request.form stuff even when you initially visit the route via a browser and no form data is sent (as it’s a GET request).
Try this:

@app.route('/owner-dashboard', methods=["POST"])
def set_keys():
  form = request.form
  card = {"name": form["cardname"], "front": form["cardfront"], "back": form["cardback"]}
  db[card.get("name")] = card

@app.route('/owner-dashboard')
def owner_dashboard():
  return render_template('ownerdash.html')

I’d have preferred flask to be a little more helpful here and error out as soon as you try to access request.form on a route which doesn’t have a methods argument (and so is GET-only) :person_shrugging:

2 Likes

@UMARismyname Now allows me to access the page but still not possible to upload either image or submit.