5.2.6 • Published 13 days ago

noer v5.2.6

Weekly downloads
-
License
MIT
Repository
-
Last release
13 days ago

noer

Simple node webserver

https://github.com/alexsch01/noer

Calculator Example

public/index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Calculator</title>
</head>
<body>
    <h1>Calculator</h1>
    <form method="post">
        <input name="left">
        <input name="right">
        <button name="add">Add</button>
    </form>
    <br>
    <form method="post">
        <input name="left">
        <input name="right">
        <button name="subtract">Subtract</button>
    </form>
    <br>
    <form method="post">
        <input name="left">
        <input name="right">
        <button name="multiply">Multiply</button>
    </form>
    <br>
    <form method="post">
        <input name="left">
        <input name="right">
        <button name="divide">Divide</button>
    </form>
    @{results}
</body>
</html>

server.js

const noer = require('noer')

noer('public/index.html', [8080], (serveHTML, data) => {
    let answer, operator
    const left = parseFloat(data.left)
    const right = parseFloat(data.right)

    if('add' in data) {
        answer = left + right
        operator = '+'
    }
    if('subtract' in data) {
        answer = left - right
        operator = '-'
    }
    if('multiply' in data) {
        answer = left * right
        operator = 'x'
    }
    if('divide' in data) {
        answer = left / right
        operator = '/'
    }

    if(Number.isFinite(answer)) {
        serveHTML({results: `<p>${left} ${operator} ${right} = ${answer}</p>`})
    }
})

How To Run

A file gets read from storage on the first call, then subsequent calls to this file use memory

node server.js

In a web browser, go to http://localhost:8080

Dev Mode

A file gets read from storage on all calls

node server.js --dev

In a web browser, go to http://localhost:8080

5.2.6

13 days ago

5.2.5

1 month ago

5.2.4

2 months ago

5.2.3

2 months ago

5.2.2

2 months ago

5.2.1

3 months ago

5.2.0

3 months ago

5.1.0

3 months ago

5.0.0

3 months ago

2.0.0

8 months ago

3.4.0

7 months ago

3.2.2

7 months ago

3.3.0

7 months ago

3.2.1

7 months ago

3.1.0

7 months ago

3.4.2

7 months ago

3.2.4

7 months ago

3.4.1

7 months ago

3.2.3

7 months ago

3.0.0

7 months ago

4.1.0

7 months ago

4.0.1

7 months ago

4.0.0

7 months ago

4.2.1

7 months ago

4.2.0

7 months ago

1.3.0

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago