The following message is reproduced verbatim from the Alpha Message board and we have turned it into a blog post because we think it will be of interest to developers using Alpha Anywhere
"One thing that has had surprisingly little attention is Alpha Anywhere's ability to run server side javascript. This is just an amazing feature. This feature makes also possible to run javascript directly in web page template. Little Example templateCode:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Little Example</title> <%= new Date() %> </head> <body> <h1>My Little Example Template</h1> </body> </html>
This is possible because Alpha Anywhere has integrated Node.js - https://en.wikipedia.org/wiki/Node.js
What is interesting is that above page is rendered in Nodejs server not in Alpha Anywhere server so if you are running AA server in port 80 you can for example make above page available at port 3000 ( or any other port). This opens endless possibilities from a developers point of view. Here is example to get started. 1. Find in Alphas install directory node_services directory and put this file expressown.js to it.Code:
exports.handler = function(packet,response,sendResponse) { var express = require('express'); var path = require('path'); var app = express(); app.set('view engine', 'ejs'); app.set('views', path.join(__dirname, 'views')); // Start the app app.get('/', function(req, res) { res.render('index'); }); app.listen(3000, function() { console.log('Express app started on port 3000'); }); response.result = 'Server is running on port 3000' sendResponse(response); };
Code:
<%a5 dim n as Helper::V8 dim p as p p._id = api_uuidcreate() p._command = "expressown" dim jsoncmd as c jsoncmd = json_generate(p) ? n.NodeRequest(jsoncmd) ? p._command %>
Comment