nodejs_on_metaarray
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
nodejs_on_metaarray [2022/01/20 19:12] – created, moved from "NodeJs" page, but I can't delete old pages! peteyboy | nodejs_on_metaarray [2024/09/06 06:02] (current) – ld’ hc9 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Setting up a simple Node.js Server | ||
+ | |||
+ | You can try Node.js by using your [[meta_port_allocation |Port Allocation]] on the [[metaarray |The MetaArray]] to run your own Node.js server. What follows is a bare-bones ‘Hello, World’ example tailored for the metaarray: | ||
+ | - go to a project folder in your user folder, say '' | ||
+ | - use your favorite editor to open a new file called '' | ||
+ | *paste the following code into the file: < | ||
+ | // | ||
+ | const hostname = ' | ||
+ | // | ||
+ | const port = 8388; | ||
+ | |||
+ | const server = http.createServer((req, | ||
+ | | ||
+ | | ||
+ | | ||
+ | }); | ||
+ | |||
+ | server.listen(port, | ||
+ | console.log(`Server running at http:// | ||
+ | });</ | ||
+ | - run the server with '' | ||
+ | - OMG that was so easy, right? Check it out with a browser pointed to your metaarray website but at your UID port, for example '' | ||
+ | * it should look like the image to the right {{ : | ||
+ | - quit the server with '' | ||
+ | - knock yourself out doing more cool stuff with javascript on the server! | ||