<p dir="auto">Hi,<br>
I come from a java background and I love using flask. But there is some itch with flask GET/POST API (production code and test code) I would like to discuss about.</p>
<p dir="auto">In a java servlet, it doesn't matter what http method you're using (GET, POST, PUT), you always do this to get a parameter from input :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="String username = request.getParameter(&quot;username&quot;);
String password = request.getParameter(&quot;password&quot;);"><pre class="notranslate"><code class="notranslate">String username = request.getParameter("username");
String password = request.getParameter("password");
</code></pre></div>
<p dir="auto">In flask, this is inconsistent :<br>
for a  POST, flasks "assumes" data come from a form (wich is not mandatory, you can submit data without a form) :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="username = request.form['username']"><pre class="notranslate"><code class="notranslate">username = request.form['username']
</code></pre></div>
<p dir="auto">To me, in terms of API, form is wrong. But worse, if you do a GET, you can't use form, you'll have to user args :<br>
GET :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="username = request.args['username']"><pre class="notranslate"><code class="notranslate">username = request.args['username']
</code></pre></div>
<p dir="auto">I would prefer to see, in POST/GET/PUT/whatever (I'm using parameter, as in java HttpServlet API) :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="username = request.parameter['username']"><pre class="notranslate"><code class="notranslate">username = request.parameter['username']
</code></pre></div>
<p dir="auto">As Im doing TDD, I observed the same inconsiancy in writing unit tests :<br>
to test a POST, you can submit a dict (which is great and very pythonic) :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="app.test_client().post('/login', data=dict(
        username=username,
        password=))"><pre class="notranslate"><code class="notranslate">app.test_client().post('/login', data=dict(
        username=username,
        password=))
</code></pre></div>
<p dir="auto">to test a GET, you can't pass a dict, you have to reconstruct the URL (which I don't find very pythonic) :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="app.test_client().get('/agent/login?username=%s&amp;password=%s' % (username, password))"><pre class="notranslate"><code class="notranslate">app.test_client().get('/agent/login?username=%s&amp;password=%s' % (username, password))
</code></pre></div>
<p dir="auto">I would love to be able to write this for a GET too :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="app.test_client().get('/login', data=dict(
        username=username,
        password=))"><pre class="notranslate"><code class="notranslate">app.test_client().get('/login', data=dict(
        username=username,
        password=))
</code></pre></div>
<p dir="auto">Anyway, what do you think ?<br>
Thanks for your feedback.</p>
<p dir="auto">Flask started to ship with a default, hardcoded logging handler. Unfortunately this setup makes it harder to install custom logging setups, because then you'll have to undo all the things Flask did to the app logger, or replace the <code class="notranslate">app.logger</code> entirely. A symptom of this is <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="173206740" data-permission-text="Title is private" data-url="https://github.com/pallets/flask/issues/1993" data-hovercard-type="pull_request" data-hovercard-url="/pallets/flask/pull/1993/hovercard" href="https://github.com/pallets/flask/pull/1993">#1993</a>, where Flask's own logger had to be tweaked yet again such that messages didn't get logged twice (once via Flask's setup, once via the custom one).</p>
<p dir="auto">My question is: <strong>Do we even want Flask to do any logging setup?</strong> It appears that this sort of default logging is only useful during development, so maybe it makes sense to set up a default logging handler in the new Flask CLI instead of from within the application.</p>