pretty print json.
This commit is contained in:
parent
661f83e38f
commit
c2fe3249ea
|
@ -5,13 +5,14 @@ import asyncio
|
|||
import os
|
||||
import signal
|
||||
import socket
|
||||
import json
|
||||
import sys
|
||||
|
||||
import aioxmpp
|
||||
import aioxmpp.dispatcher
|
||||
from aiohttp import web
|
||||
|
||||
__version__ = "0.1"
|
||||
__version__ = "0.2"
|
||||
|
||||
|
||||
class XMPPClient:
|
||||
|
@ -55,7 +56,11 @@ class HTTPServer:
|
|||
async def on_post(self, request):
|
||||
if not self.xmpp_client:
|
||||
return
|
||||
self.xmpp_client.send(await request.text(), self.to_jid)
|
||||
data = await request.text()
|
||||
try:
|
||||
self.xmpp_client.send(json.dumps(json.loads(data), indent=4), self.to_jid)
|
||||
except json.JSONDecodeError:
|
||||
self.xmpp_client.send(data, self.to_jid)
|
||||
return web.Response(text="")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue