1.1.3 • Published 5 years ago

thecoder08-http v1.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

HTTP

What is HTTP?

HTTP is a simple-syntax yet powerful web server developed by thecoder08.

Installation

Run the command

npm i thecoder08-http

to install HTTP.

Require

Require with this code for node.js:

var http = require('thecoder08-http');

Require with this code for the browser:

<script src="node_modules/thecoder08-http/browser.js"></script>

Syntax

Node.js

http.server(port, callback);

Where port is a number for the port to run the server on.
Where callback is a function with arguments req, a url object from the request, res, a function that responds to the client, It's syntax is below:

res(status, type, data);

Where status is a number for the response status code.
Where type is the MIME type for the data to respond.
Where data is the data to respond.
and redirect, a function that redirects the client. It's syntax is below:

redirect(message, url);

Where message is a message to tell the client they are redirecting.
Where url is the URL to redirect to.

http.secureServer(cert, key, port, callback)

Syntax for secureServer is the same as that of server. The only difference is that cert is the SSL certificate for the server, and key, is the private key.

http.request(options, callback);

Where options is an object with properties hostname, the address of the server to request, port, the port of the server to request, and path, the path to request the server.
Where callback is a function with an argument data, the data from the server.

Browser

request(url, callback);

Where url is the URL to request.
Where callback is a function with an argument data, the data from the server.

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago