Javascript web server?

Is it possible to build a micro web server (proof of concept) in Javascript?

Has anyone done this before?


EDIT: Obviously, an explicit explanation is required here. The question ultimately is how to transfer data from the server to the browser after the initial request made by the browser was closed. In other words, how to make the browser accept subsequent requests initiated by the server.

Should a javascript-based web server be installed in the browser or is there some other method?

+6
javascript
source share
6 answers

If you say that you want to use data for browsers that initiated contact with your server, I would do some research on Comet servers.

I don’t know anything about this, so I’ll just give you a couple of links to you, which I hope will point you in the right direction.

From Wikipedia Comet_ (programming)

Comet is a web application model in which a long HTTP request allows the web server to send data to the browser without an explicit request from the browser. 1 Comet is an umbrella term that encompasses many methods to achieve this interaction. All of these methods rely on features enabled by default in browsers, such as JavaScript, rather than plugins other than the default. The Comet approach is different from the original network model, in which the browser requests a full web page at a time. [3]

Something here is called APE. I don't know anything about this, but you may find it useful.

From the APE website:

APE is a full-featured OpenSource solution designed for Ajax Push. It includes a comet server and Javascript Framework. APE allows you to implement any streams of real-time data in a web browser without the need to install anything on the client side.

+3
source share

Check out the RingoJS project or Node.js. The answer is yes, not just micro or proof of concept.

Ringojs

Node.js

express.js framework for node

+15
source share

There is an add-on for Firefox (also available as a standalone desktop application) called The Normal Web Server . It should be able to run a special kind of server-side JavaScript, which has access to all the internal functions of the web browser, including access to the local file and SQLite databases, access to browser preferences and history, and everything else that can be done with the Firefox add-in.

+1
source share

Have you seen the Juggernaut? https://github.com/maccman/juggernaut/blob/master/README.md You will have to forgive, I'm not sure that this is exactly what you are looking for, and I'm a little noob, but readme made it sound like a good fit for what you are describing.

0
source share

JS HTTPD

http://acme.com/software/js_httpd/

It is a small UNIX server written in JavaScript.

It runs on inetd, which means its performance is low. But for sites with low traffic, this is quite adequate. It implements all the basic functions of an HTTP server, including:

  • Protection against ".." filename snooping.
  • Common MIME Types.
  • Redirecting trailing slash.
  • index.html
  • Directory Lists.

js_httpd can also be used to serve HTTPS by wrapping it with stunnel. Instructions included.

Other tiny and / or weird web servers (all run from inetd):

http://acme.com/software/js_httpd/

0
source share

You can try: "ewsjs is a built-in web server inside your browser. When developing applications based on Ajax and single-page applications, it is often difficult to test these applications until the web server is installed. (...)

EWS provides an embedded web server that accesses your Ajax application as if it were coming from a server. You can use any logic and fully test your Ajax application in a browser without starting the server.

EWS supports several key functions: Register handlers for any path, Register handlers for parameterized paths (for example, Sinatra routes), Register handlers for automatic (when no other handler matches), Rewrite one path to another (for example, in Apache or nginx) , asynchronous (accurately mimicking true ajax calls) "

on https://github.com/deitch/ewsjs

0
source share

All Articles