title: How to handle missing parameters in URL with Flask/Python 3
body: <p>Currently, my website has two drop down boxes on it whose values, upon form submission, translate to two URL parameters "myState" and "myShelter". For example:</p>
  
  <p><a href="https://www.atweather.org/forecast?myState=CT&amp;myShelter=181" rel="nofollow noreferrer">https://www.atweather.org/forecast?myState=CT&amp;myShelter=181</a></p>
  
  <p>I'm now adding a third box and there will be a third corresponding parameter called "myTrail". My question is this: how can I make it so that if someone directly submits a URL with just the two parameters, the browser will not error out with a bad request? I would want the user to see the page as though "myState" and "myShelter" were picked, but "myTrail" was just left unselected.</p>
  
  <p>I tried looking <a href="https://stackoverflow.com/questions/14032066/flask-optional-url-parameters">here</a> and <a href="https://stackoverflow.com/questions/15166142/flask-optional-url-parameter-not-working">here</a>, but I don't think these are quite the same situation as what I'm asking about. I'm using Flask under Python 3 and currently handle this route like so:</p>
  
  <pre><code>@app.route('/forecast', methods = ['GET'])
  def forecast(loc_state = None, loc_id = None):
  
      """
      Handles rendering of page after a location has been selected
      """
  
      loc_state = request.args['myState']
      loc_id = int(request.args['myShelter'])
  
      ...and a bunch of other logic for rendering the page...
  </code></pre>
  
  <p>Thanks in advance for any insight!</p>