yes, après pour ceux qui ont pas le temps vous pouvez ajouter ce code à la racine de LaBot pour créer une API
#!/usr/bin/python3
import binascii
import json
import logging
import os
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse
from labot.data import Msg, Buffer
class S(BaseHTTPRequestHandler):
def _set_response(self):
self.send_response(200)
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Content-type', 'application/json')
self.end_headers()
def do_GET(self):
self._set_response()
try:
query = urlparse(self.path).query
query_components = dict(qc.split("=") for qc in query.split("&"))
te = Msg.fromRaw(
Buffer(bytearray.fromhex(query_components["hexa"])),
"client" in query_components and query_components["client"] == 'true'
).json()
if te is None:
self.wfile.write(json.dumps({'error': 'true'}).encode())
else:
if 'hash_function' in te:
te['hash_function'] = None
self.wfile.write(json.dumps({'data': te}).encode())
except:
self.wfile.write(json.dumps({'error': 'true'}).encode())
def log_message(self, format, *args):
return
def run(server_class=HTTPServer, handler_class=S, port=5000):
logging.basicConfig(level=logging.INFO)
server_address = ('', port)
httpd = server_class(server_address, handler_class)
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
httpd.server_close()
if __name__ == '__main__':
run()