Skip to content
This repository was archived by the owner on Dec 29, 2023. It is now read-only.

Commit 9c00af7

Browse files
authored
Merge pull request #6 from chdb-io/api
improve API compatibility
2 parents 4028dc0 + 8b954eb commit 9c00af7

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

main.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ def chdb_query_with_errmsg(query, format):
4949
@auth.login_required
5050
def clickhouse():
5151
query = request.args.get('query', default="", type=str)
52-
format = request.args.get('default_format', default="CSV", type=str)
52+
format = request.args.get('default_format', default="TSV", type=str)
5353
if not query:
54-
return app.send_static_file('play.html')
54+
return "Ok", 200
55+
# return app.send_static_file('play.html')
5556

5657
result, errmsg = chdb_query_with_errmsg(query, format)
5758
if len(errmsg) == 0:
@@ -62,17 +63,26 @@ def clickhouse():
6263
@app.route('/', methods=["POST"])
6364
@auth.login_required
6465
def play():
65-
query = request.data
66-
format = request.args.get('default_format', default="CSV", type=str)
66+
query = request.data or None
67+
format = request.args.get('default_format', default="TSV", type=str)
6768
if not query:
68-
return app.send_static_file('play.html')
69+
return "Ok", 200
70+
# return app.send_static_file('play.html')
6971

7072
result, errmsg = chdb_query_with_errmsg(query, format)
7173
if len(errmsg) == 0:
7274
return result
7375
return errmsg
7476

7577

78+
@app.route('/play', methods=["GET"])
79+
def handle_play():
80+
return app.send_static_file('play.html')
81+
82+
@app.route('/ping', methods=["GET"])
83+
def handle_ping():
84+
return "Ok", 200
85+
7686
@app.errorhandler(404)
7787
def handle_404(e):
7888
return app.send_static_file('play.html')

0 commit comments

Comments
 (0)