initial commit
This commit is contained in:
commit
cf8a823ad8
4 changed files with 71 additions and 0 deletions
27
shit.mjs
Normal file
27
shit.mjs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import {appendFile, readFile} from 'node:fs/promises';
|
||||
import {createServer} from 'node:http';
|
||||
|
||||
createServer(async (request, response) => {
|
||||
const chat = new URL(`http://a${request.url}`).searchParams.get('chat');
|
||||
if (chat) {
|
||||
await appendFile('a.txt', `${chat}\n`, {flag: 'a+', encoding: 'utf8'});
|
||||
response.writeHead(303, {location: '/'}).end(); // without query
|
||||
} else {
|
||||
response.writeHead(200, {
|
||||
'content-type': 'text/html',
|
||||
'refresh': '30', // lfmoa
|
||||
}).end(
|
||||
`<pre>${
|
||||
(await readFile('a.txt', {flag: 'a+', encoding: 'utf8'}))
|
||||
// ugh, fine, i'll html escape it. no xss for you
|
||||
.replace(/[<>&'"]/g, match => ({
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'&': '&',
|
||||
'\'': '&apos',
|
||||
'"': '"',
|
||||
})[match])
|
||||
}</pre><form><input type=text name=chat autofocus><button>send`
|
||||
);
|
||||
}
|
||||
}).listen(process.env.PORT || 80, () => console.log(`hiiiii ^w^ hai hii :3`));
|
||||
Loading…
Add table
Add a link
Reference in a new issue