External javascript method 2
external javascript method 2
serving with nodejs
- by running it with
node server.js
- create your html file and save it (e.g.
index.html) - create a server that opens a port and listens (e.g.
server.js) - write your js code in another file (e.g.
client.js) - preprocess that file with
browserify(e.g.browserify client-before -o client-after.js) server.jspoints to bothindex.htmlandclient.jsindex.htmlpoints toclient.js
external asynchronous
1x html file, 2x js file
javascript (node) starts a server through
node server.js, which serves the html file, which calls the (browserified) client.js file
(run the .js (something like node server.js and the html is served at some port))
- running a server + source code transformation
- multiple requests (because its multiple files to call)
server side
- flask as server ===
node app.js - flask/node runs the .py/.js file which generates or calls the .html file and displays it
- opens a port and listens
client side