Just twiddling with the webpage
This commit is contained in:
Родитель
b3338273b4
Коммит
1d8c4659d1
|
@ -103,7 +103,7 @@ representation is rather inefficient. This will change in the future, when <a
|
||||||
<dd> Stops a interval from triggering. </dd>
|
<dd> Stops a interval from triggering. </dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h2 id="files">node.fs</h2>
|
<h2 id="files"><code>node.fs</code></h2>
|
||||||
|
|
||||||
<p>File I/O is tricky because there are not simple non-blocking ways to do it.
|
<p>File I/O is tricky because there are not simple non-blocking ways to do it.
|
||||||
Node handles file I/O by employing <a
|
Node handles file I/O by employing <a
|
||||||
|
@ -702,8 +702,7 @@ read.
|
||||||
|
|
||||||
<p>Node has a simple module loading system. In Node, files and modules are
|
<p>Node has a simple module loading system. In Node, files and modules are
|
||||||
in one-to-one correspondence.
|
in one-to-one correspondence.
|
||||||
|
As an example,
|
||||||
<p> As an example,
|
|
||||||
<code>foo.js</code> loads the module <code>mjsunit.js</code>.
|
<code>foo.js</code> loads the module <code>mjsunit.js</code>.
|
||||||
|
|
||||||
<p>The contents of <code>foo.js</code>:
|
<p>The contents of <code>foo.js</code>:
|
||||||
|
@ -730,7 +729,7 @@ exports.assertEquals = function (expected, found, name_opt) {
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>Here the module <code>mjsunit.js</code> has exported the function
|
<p>The module <code>mjsunit</code> has exported a function
|
||||||
<code>assertEquals()</code>. <code>mjsunit.js</code> must be in the
|
<code>assertEquals()</code>. <code>mjsunit.js</code> must be in the
|
||||||
same directory as <code>foo.js</code> for <code>include()</code> to find it.
|
same directory as <code>foo.js</code> for <code>include()</code> to find it.
|
||||||
The module path is relative to the file calling <code>include()</code>.
|
The module path is relative to the file calling <code>include()</code>.
|
||||||
|
@ -742,12 +741,11 @@ from the specified module into the global namespace.
|
||||||
<p> Because file loading does not happen instantaneously, and because Node
|
<p> Because file loading does not happen instantaneously, and because Node
|
||||||
has a policy of never blocking, the callback <code
|
has a policy of never blocking, the callback <code
|
||||||
>onLoad</code> can be set and will notify the user
|
>onLoad</code> can be set and will notify the user
|
||||||
when all the included modules are loaded. Each file/module can have an <code
|
when the included modules are loaded. Each file/module can have an <code
|
||||||
>onLoad</code> callback.
|
>onLoad</code> callback.
|
||||||
|
|
||||||
<p>To export an object, add to the special <code>exports</code> object.
|
<p>To export an object, add to the special <code>exports</code> object.
|
||||||
|
The functions <code>fail</code> and <code>deepEquals</code> are not
|
||||||
<p> The functions <code>fail</code> and <code>deepEquals</code> are not
|
|
||||||
exported and remain private to the module.
|
exported and remain private to the module.
|
||||||
|
|
||||||
<p> <code>require()</code> is like <code>include()</code> except does not
|
<p> <code>require()</code> is like <code>include()</code> except does not
|
||||||
|
|
|
@ -17,26 +17,28 @@
|
||||||
<p id="introduction">Purely evented I/O for <a
|
<p id="introduction">Purely evented I/O for <a
|
||||||
href="http://code.google.com/p/v8/">V8 javascript</a>.
|
href="http://code.google.com/p/v8/">V8 javascript</a>.
|
||||||
|
|
||||||
<p>This is an example of a web server written with Node which responds with
|
<p>An example of a web server written with Node which responds with
|
||||||
"Hello World" after waiting two seconds:
|
"Hello World" after waiting two seconds:
|
||||||
|
|
||||||
<pre>new node.http.Server(function (req, res) {
|
<pre>
|
||||||
|
new node.http.Server(function (req, res) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
res.sendHeader(200, [["Content-Type", "text/plain"]]);
|
res.sendHeader(200, [["Content-Type", "text/plain"]]);
|
||||||
res.sendBody("Hello World");
|
res.sendBody("Hello World");
|
||||||
res.finish();
|
res.finish();
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}).listen(8000);
|
}).listen(8000);
|
||||||
puts("Server running at http://127.0.0.1:8000/");</pre>
|
puts("Server running at http://127.0.0.1:8000/");
|
||||||
|
</pre>
|
||||||
|
|
||||||
<p> To run the server, put the code into a file <code>server.js</code>
|
<p> To run the server, put the code into a file <code>example.js</code>
|
||||||
and execute it with the <code>node</code> program
|
and execute it with the <code>node</code> program
|
||||||
<pre class="sh_none">% /usr/local/bin/node server.js
|
<pre class="sh_none">% /usr/local/bin/node example.js
|
||||||
Server running at http://127.0.0.1:8000/
|
Server running at http://127.0.0.1:8000/
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
<p> See <a href="api.html">the API documentation</a> for more examples.
|
<p> See the <a href="api.html">API documentation</a> for more examples.
|
||||||
|
|
||||||
<p> Node is released under an MIT license.</p>
|
<p> Node is released under an MIT license.</p>
|
||||||
|
|
||||||
|
@ -48,18 +50,23 @@ Server running at http://127.0.0.1:8000/
|
||||||
<h2 id="build">Build</h2>
|
<h2 id="build">Build</h2>
|
||||||
|
|
||||||
<p>Node aims to support all POSIX operating systems (including
|
<p>Node aims to support all POSIX operating systems (including
|
||||||
Windows with mingw). However at the moment it is only being tested on
|
Windows with mingw) but at the moment it is only being tested on
|
||||||
Macintosh and Linux.
|
Linux, Macintosh, and FreeBSD.
|
||||||
|
The build system requires Python.
|
||||||
|
V8, on which Node is built, supports only IA-32 and ARM processors.
|
||||||
|
|
||||||
<p>V8, on which Node is built, supports only IA-32 and ARM processors.
|
<pre class="sh_none">
|
||||||
|
./configure
|
||||||
<p> The build system requires Python.
|
|
||||||
|
|
||||||
<pre class="sh_none">./configure
|
|
||||||
make
|
make
|
||||||
make install</pre>
|
make install
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<p>To run the unit tests
|
||||||
|
|
||||||
|
<pre class="sh_none">
|
||||||
|
./configure --debug
|
||||||
|
make test
|
||||||
|
</pre>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -44,7 +44,7 @@ h1 a, h2 a, h3 a, h4 a
|
||||||
pre, code {
|
pre, code {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
font-size: 14pt;
|
font-size: 14pt;
|
||||||
color: #fee;
|
color: #eee0e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
|
@ -52,12 +52,6 @@ pre {
|
||||||
border-left: 1px solid #444;
|
border-left: 1px solid #444;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl {
|
|
||||||
}
|
|
||||||
|
|
||||||
dt {
|
|
||||||
}
|
|
||||||
|
|
||||||
dd {
|
dd {
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче