Node.js : How to embed Node.js into HTML?

前端 未结 3 1244
一整个雨季
一整个雨季 2020-12-31 04:33

In a php file I can do:

Is there a way to do this in node, if yes what\'

3条回答
  •  滥情空心
    2020-12-31 05:40

    You can try using JooDee, a node webserver which allows you to embed serverside javascript in your web pages. If you are familiar with Node and PHP/ASP, it is a breeze to create pages. Here's a sample of what a page looks like below:

    
    
    <:  //server side code in here
        var os = require('os');
        var hostname = os.hostname();
    :>
    
        
    Your hostname is <::hostname:>

    Using JooDee also lets you expose server javascript vars to the client with no effort by attaching attributes to the 'Client' object server side, and accessing the generated 'Client' object in your client side javascript.

    https://github.com/BigIroh/JooDee

提交回复
热议问题