title: A better way to accept multiple request types in a single view method?
body: <p>I'm trying to expose an API to various request methods (GET, url x-www-form-urlencoded POST, and json POST):</p>
  
  <pre><code>@app.route('/create', methods=['GET', 'POST'])
  def create_file():
      if request.method == 'GET':
          n = request.args.get('n')
          t = request.args.get('t')
      if request.method == 'POST':
          if request.json:
              n = request.json['n']
              t = request.json['t']
          else:
              n = request.form['n']
              t = request.form['t']
      try:
          n = int(n)
      except:
          n = 1
      ...
  </code></pre>
  
  <p>The above appears too verbose. Is there a simpler or better way of writing this? Thanks.</p>