Skip to content

Commit 8b3067d

Browse files
committed
feat: add static file serving and update image handling in Pug template
1 parent 2ccfcf2 commit 8b3067d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

samples/sample-app/server/server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const path = require('path');
88
const pugTemplatePath = path.join(__dirname, "../views/index.pug");
99

1010
const app = express();
11+
app.use(express.static('static'))
1112
app.use(cors());
1213
app.set('view engine', 'pug');
1314

samples/sample-app/views/index.pug

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
html
22
body
3+
img(id="my-image")
34
h3 Imagekit Demo
45
form(action='#' onSubmit='upload(event)')
56
input(type='file' id='file1')
@@ -18,16 +19,29 @@ html
1819
p
1920
img(src="")
2021

21-
script(type='text/javascript' src="https://unpkg.com/imagekit-javascript/dist/imagekit.min.js")
22+
// Copy paste manually from dist
23+
script(type='text/javascript' src="./imagekit.min.js")
2224
script.
2325
try {
2426
var imagekit = new ImageKit({
2527
publicKey: "!{publicKey}",
2628
urlEndpoint: "!{urlEndpoint}",
2729
});
2830

31+
2932
window.imagekit = imagekit;
3033

34+
var url = imagekit.url({
35+
src: "https://ik.imagekit.io/demo/default-image.jpg",
36+
transformation: [{
37+
height: 100
38+
}]
39+
})
40+
41+
var img = document.getElementById("my-image");
42+
console.log(url);
43+
img.src = url;
44+
3145

3246
function upload(e) {
3347
e.preventDefault();
@@ -119,4 +133,4 @@ html
119133
}
120134
} catch(ex) {
121135
console.log(ex);
122-
}
136+
}

0 commit comments

Comments
 (0)