Basic steps needed:
- Go to https://nodejs.org/en/
- Download Node.JS for your OS and Install (there are versions for every OS SB supports)
- Create an empty directory for your Node.JS project somewhere
- Go to the directory
- type "npm init" <press enter> and just accept all defaults (<press enter> some more)
- type "npm install express --save" <press enter>
- create a file called "main.js" with the code I provided below.
- create another directory called "sbclient" inside the Node.JS project directory (Node will serve static files, that is: your SB program, from here)
- create an empty file in this directory called "index.html"
- Open compiler options in SB and point your export settings "HTML filename" to the index.html file in the "sbclient" directory you just created.
- Make sure you check the checkbox called "Copy SpiderBasic libraries"
- Close the compiler options dialog with OK-button
- In SB menu use "compiler"->"export" (the "sbclient" library should now be populated with your project.)
- Go back to the Node.JS directory with terminal (OS X/Linux) or cmd.exe (Windows)
- Type "node main.js" <press enter>
- In your web browser write the address: "localhost:3000" <press enter>
- (If you want to stop the server (or restart it after making changes) Press CTRL+C)
It's very easy to extend the main.js with url-handlers so that you can use HTTPRequest from SB and get results from server side, but I'll leave that as an exercise to you. (Google some examples/tutorials from the Express JS web site)
Someone mentioned web hosting, and I'd recommend using one that explicitly supports Node.JS if you go this path. Then "Long running process" is no problem.
main.js
Code: Select all
var express = require('express')
var app = express()
app.use(express.static(__dirname + '/sbclient'));
var server = app.listen(3000, function() {
a = server.address();
console.log('App listening at http://%s:%s', a.address, a.port);
})