cgi-getparameters
v1.0.12
Published
Gets POST, GET and JSON parameters when node is used as an apache CGI
Downloads
15
Readme
Description
A node.js module to get GET and POST parameters when running node as an apache CGI program
Install
npm install cgi-getparameters
Examples
#!/usr/local/bin/node
"use strict"
const
getParameters= require("cgi-getparameters").getParameters,
fs = require('fs'),
DataURI = require('datauri').promise,
echo = console.log
echo(`Content-Type: text/html; charset=utf-8\n`)
getParameters().then($_ => {
echo(`<pre>`)
echo("POST",JSON.stringify($_.POST, 4, 4))
echo("GET",JSON.stringify($_.GET, 4, 4))
echo(`</pre>`)
Object.entries($_.FILE).forEach(([name, files]) => {
if (!files.length)
files=[files]
files.forEach(file=>{
DataURI(file.tName).then(uri =>{
echo(name)
echo(`<img src="${uri}" alt="${file.filename}">`)
})
})
})
}).catch(console.error)