|
1 day ago | |
---|---|---|
Readme.md | 1 day ago | |
index.html | 1 day ago | |
script.js | 1 day ago |
Readme.md
Basic procedure to init a JS proyect
This basic repository shows how to prepare basic JS apps to run and test in Unix like OS. The guide use the serve
node package installed globally; alternally you can use live server
extension in visual studio code to mount a basic server for testing.
1. Create the project directory
mkdir my-js-project
cd my-js-project
2. Create the basic files
touch index.html
touch script.js
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test JS</title>
</head>
<body>
<h1>Hello Blink!</h1>
<button onclick="sayHello()">Click me</button>
<script src="script.js"></script>
</body>
</html>
script.js
function sayHello() {
alert("Hello from JS!");
console.log("Hello from script.js!");
}
3. Install a simple static server
If you want to serve this app via a web browser use:
npm install -g serve
This will install globally, if you already do not have installed, and then you can use later for this or further js projects:
serve .
By default it serves on http://localhost:3000
4. Access it in the web browser
Once you execute the serve
commmand a prompt will let you know where your server is serving:
Serving! ││ ││ - Local: http://localhost:3000 ││ - Network: http://172.18.0.2:3000
thus, you can visit it locally or in other device with the network
address.
Note: if you are using Blink Shell app for iPad you must open other Blink terminal and forward the the exposed port:
Blink> build port add htools 3000 3000
after that you will be able to open the app only directly from your iPad if you did it by Blink Build
. Otherwise, the app will be abaileble at the provided URL.