[WORK] Новый UI на сервисах (8096): конструктор с автозаполнением, чек-лист полноты, кабельный журнал, схема, матрица, документы; экспорт BOM в XLSX
This commit is contained in:
1 parent
9350addb15
commit
f0260e9842
3 files changed
+460
-1
No files matched your search
@@ -17,7 +17,20 @@ def serve(routes, port, name):
|
||||
"""routes: {path: callable(q: dict, body: dict|None) -> dict}"""
|
||||
|
||||
class H(BaseHTTPRequestHandler):
|
||||
def _send_file(self, data, filename, ctype):
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Disposition", 'attachment; filename="%s"' % filename)
|
||||
self.send_header("Content-Length", str(len(data)))
|
||||
for k, v in CORS.items():
|
||||
self.send_header(k, v)
|
||||
self.end_headers()
|
||||
self.wfile.write(data)
|
||||
|
||||
def _send(self, obj, code=200):
|
||||
if isinstance(obj, dict) and obj.get("__file__"):
|
||||
return self._send_file(obj["__file__"], obj.get("filename", "file"),
|
||||
obj.get("content_type", "application/octet-stream"))
|
||||
body = json.dumps(obj, ensure_ascii=False).encode()
|
||||
self.send_response(code)
|
||||
self.send_header("Content-Type", "application/json; charset=utf-8")
|
||||
|
||||
Reference in new issue
Block a user