title: Bad Request - The browser (or proxy) sent a request that this server could not understand
body: <p>I'm trying to create a flask app where I have a text box on the webpage. When submit is pressed it searches what was entered into the text box in a postgres datbase table.</p>
  
  <p>I'm getting the following error:</p>
  
  <blockquote>
    <p><strong>Bad Request</strong> The browser (or proxy) sent a request that this server could not
    understand."</p>
  </blockquote>
  
  <p>My code is as follows: </p>
  
  <blockquote>
    <p>app.py</p>
  </blockquote>
  
  <pre><code>from flask import Flask, render_template, request
  from sqlalchemy import create_engine
  
  app = Flask(__name__)
  app.config['DEBUG']
  
  db_string = "postgres://xx:xx@xx:5432/xx"
  
  db = create_engine(db_string)
  
  @app.route('/', methods=['GET', 'POST'])
  def homepage():
      jn = request.form['jobnumber']
      result_set = db.execute("SELECT cost FROM public.options where optionno = (f'%{jn}%')").fetchall()
      return render_template('main.html', test=result_set, jn=jn)
  
      if __name__ == "__main__":
          app.run(debug=True)
  </code></pre>
  
  <p>and my html file:</p>
  
  <blockquote>
    <p>main.html</p>
  </blockquote>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;xxx&lt;/title&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet"&gt;
      &lt;link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;p&gt;xxx&lt;/p&gt;
  
  &lt;form method="POST"&gt;
      &lt;input name="jobnumber" type="submit" placeholder="jn"&gt;
  &lt;/form&gt;
  
  &lt;table&gt; 
  
  &lt;td&gt;
         {{test}}
  
  &lt;/td&gt;
  
  
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I'm sure it's something real easy and simple that will fix it, but i'm struggling so any help would be hugely appreciated.</p>