~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH core.sr.ht] Gracefully handle errors coming from the QGL server

Details
Message ID
<20210113052638.12248-1-ludovic@chabant.com>
DKIM signature
pass
Download raw message
Patch: +9 -6
---
 srht/graphql.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/srht/graphql.py b/srht/graphql.py
index f3b8119..483d178 100644
--- a/srht/graphql.py
+++ b/srht/graphql.py
@@ -22,12 +22,15 @@ def execute_gql(query):
            cookies=request.cookies,
            headers={"Content-Type": "application/json"},
            json={"query": query})
    j = json.dumps(r.json(), indent=2)
    lexer = JsonLexer()
    formatter = HtmlFormatter()
    style = formatter.get_style_defs('.highlight')
    html = (f"<style>{style}</style>"
            + highlight(j, lexer, formatter))
    if r.ok:
        j = json.dumps(r.json(), indent=2)
        lexer = JsonLexer()
        formatter = HtmlFormatter()
        style = formatter.get_style_defs('.highlight')
        html = (f"<style>{style}</style>"
                + highlight(j, lexer, formatter))
    else:
        html = (f"<p>graphql execution returned code {r.status_code}</p>")
    return Markup(html)

@gql_blueprint.route("/graphql")
-- 
2.19.1
Details
Message ID
<C8I446EGFKR7.2GEPA9NWJUIIE@taiga>
In-Reply-To
<20210113052638.12248-1-ludovic@chabant.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Thanks!

To git@git.sr.ht:~sircmpwn/core.sr.ht
   8abd7e9..4972e01  master -> master
Reply to thread Export thread (mbox)