summaryrefslogtreecommitdiff
path: root/extras/appengine/sqlformat
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2011-12-15 08:56:57 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2011-12-15 08:56:57 +0100
commit311291ae58fd6baae47fff7b1efd8c47c102c25c (patch)
tree17ad2a2a80707c435e53a2c8616b2386d480a29b /extras/appengine/sqlformat
parent8953118a6dc4618ff8eb44a7cd0ff427de198c2f (diff)
downloadsqlparse-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.py5
-rw-r--r--extras/appengine/sqlformat/templates/api.html20
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 %}