A
A
Adilet Usonov2020-11-08 15:35:13
Flask
Adilet Usonov, 2020-11-08 15:35:13

Does Flask request throw an error?

In short here is the python code

#import
from flask import Flask, render_template
from flask import request
from werkzeug.exceptions import BadRequestKeyError

#init
app = Flask(__name__)


#create pages
@app.route('/')
def SayHello():
  return 'Why it is not working :('

@app.route('/class_founder', methods=['GET'])

def check():
  
  key = request.form['text']

swap = True

#run app
app.run(debug=True)

And here is the html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Having time</title>
  <link rel="stylesheet" href="static/style.css">
</head>
<body>
  <section>
    <form method="GET" action="/class_founder">
      <input name='text' type="text">
        <input type="submit" class="button" value="Start">
            
    </form>
    
    <div class="box">
      <div class="bar" name='teacher_box'></div>
      <div class="bar" name='subject_box'></div>
      <div class="bar" name='student_box'></div>
    </div>
  </section>

</body>
</html>


I save, update in the console, open in the browser
And there is a BadRequestKeyError error saying that the browser sent a request that the server cannot
understand. I wrote everything correctly 100% input name
and request.form are the same. Inet already ransacked
HELP PZH!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2020-11-08
@soremix

I wrote everything correctly 100%

For some reason the code doesn't work. Miracles and more.
request - what do you have?

D
Dr. Bacon, 2020-11-08
@bacon

well, the GET method, the data is in request.args, not in request.form

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question