From b13d5c741b2a552ad80a9ba2e6e63d6f6175580b Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Tue, 10 Dec 2019 21:06:50 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:=20img.src=E3=81=AB=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E3=81=AA=E3=83=A1=E3=82=BF=E6=83=85=E5=A0=B1=E3=82=92=E3=83=95?= =?UTF-8?q?=E3=83=AD=E3=83=B3=E3=83=88=E3=82=A8=E3=83=B3=E3=83=89=E3=81=A7?= =?UTF-8?q?=E4=BB=98=E4=B8=8E=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=20#22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- websh_front/src/index.nim | 3 ++- websh_server/src/websh_server.nim | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/websh_front/src/index.nim b/websh_front/src/index.nim index 539911c..6fdf354 100644 --- a/websh_front/src/index.nim +++ b/websh_front/src/index.nim @@ -74,7 +74,8 @@ proc createDom(): VNode = h4: text "Images" for img in outputImages: tdiv: - img(src = img) + # imgでbase64を表示するときに必要なメタ情報を追加 + img(src = "data:image/png;base64," & img) footer(class = &"page-footer {baseColor}"): tdiv(class = "footer-copyright"): tdiv(class = "container"): diff --git a/websh_server/src/websh_server.nim b/websh_server/src/websh_server.nim index 0f18b2d..66aa60d 100644 --- a/websh_server/src/websh_server.nim +++ b/websh_server/src/websh_server.nim @@ -94,10 +94,7 @@ router myrouter: let (dir, name, ext) = splitFile(path) if ext.toLowerAscii notin [".png", ".jpg", ".jpeg", ".gif"]: continue - # JavaScriptのimg.srcにセットする時のプレフィックス - let meta = "data:image/png;base64," - let data = meta & base64.encode(readFile(path)) - images.add(data) + images.add(base64.encode(readFile(path))) resp %*{"stdout":stdoutStr, "stderr":stderrStr, "images":images} get "/ping":