diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2011-12-15 08:56:57 +0100 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2011-12-15 08:56:57 +0100 |
| commit | 311291ae58fd6baae47fff7b1efd8c47c102c25c (patch) | |
| tree | 17ad2a2a80707c435e53a2c8616b2386d480a29b /extras/appengine/sqlformat | |
| parent | 8953118a6dc4618ff8eb44a7cd0ff427de198c2f (diff) | |
| download | sqlparse-311291ae58fd6baae47fff7b1efd8c47c102c25c.tar.gz | |
Update API documentation and simplify usage of reindent option.
Diffstat (limited to 'extras/appengine/sqlformat')
| -rw-r--r-- | extras/appengine/sqlformat/legacy.py | 5 | ||||
| -rw-r--r-- | extras/appengine/sqlformat/templates/api.html | 20 |
2 files changed, 21 insertions, 4 deletions
diff --git a/extras/appengine/sqlformat/legacy.py b/extras/appengine/sqlformat/legacy.py index b563a38..7f6c161 100644 --- a/extras/appengine/sqlformat/legacy.py +++ b/extras/appengine/sqlformat/legacy.py @@ -73,6 +73,7 @@ def api(): @legacy.route('/format/', methods=['GET', 'POST']) +@legacy.route('/format', methods=['GET', 'POST']) def format_(): if request.method == 'POST': sql = _get_sql(request.form, request.files) @@ -140,6 +141,10 @@ def _format_sql(sql, data, format='html'): popts['reindent'] = True except (ValueError, TypeError): pass + if (not 'indent_width' in popts and + data.get('reindent', '').lower() in ('1', 'true', 't')): + popts['indent_width'] = 2 + popts['reindent'] = True if data.get('output_format', None) is not None: popts['output_format'] = data.get('output_format') logging.debug('Format: %s, POPTS: %r', format, popts) diff --git a/extras/appengine/sqlformat/templates/api.html b/extras/appengine/sqlformat/templates/api.html index 79bf118..ebfd83a 100644 --- a/extras/appengine/sqlformat/templates/api.html +++ b/extras/appengine/sqlformat/templates/api.html @@ -7,7 +7,7 @@ <p> Using the API for this application is pretty simple. Just send a - <code>POST</code> request to + request to </p> <p> <code>http://sqlformat.appspot.com/format/</code> @@ -15,9 +15,10 @@ <h2>Options</h2> <p> - The <code>POST</code> request accepts various options to control - formatting. Only the <em>data</em> option is required. All others - are optional. + The server accepts various options to control formatting. Only + the <em>data</em> option is required. All others are optional.<br /> + Either use <code>GET</code> and pack the options in the query string + or <code>POST</code> and submit your parameters as form data. </p> <dl> @@ -49,4 +50,15 @@ <a href="/static/sqlformat_client_example.py">Download sqlformat_example_client.py</a> </p> +<p> + And another example using curl and a <code>GET</code> request: +</p> +<div class="highlight example"><pre> +$ curl "http://localhost:8080/format<b>?</b>keyword_case=upper<b>&</b>reindent=true<b>&</b>data=select%20*%20from%20foo;" +SELECT * +FROM foo; +$ +</pre></div> + + {% endblock %} |
