test
This commit is contained in:
parent
bbb19375cf
commit
8a93df3e09
@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "tsx src/index.ts"
|
||||
"dev": "nodemon --watch src --exec tsx src/index.ts"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "abearxiong <xiongxiao@xiongxiao.me>",
|
||||
|
13
src/app.ts
13
src/app.ts
@ -25,7 +25,8 @@ const server = http.createServer((req: http.IncomingMessage, res) => {
|
||||
res.end('Method not allowed');
|
||||
return;
|
||||
}
|
||||
const vivid = new Vivid();
|
||||
|
||||
const vivid = new Vivid({ pathname });
|
||||
const accept = req.headers['accept'];
|
||||
if (accept && accept.includes('text/html')) {
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
@ -37,6 +38,16 @@ const server = http.createServer((req: http.IncomingMessage, res) => {
|
||||
res.end(`console.log(new Date())`);
|
||||
return;
|
||||
}
|
||||
if (accept && accept.includes('text/plain')) {
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
res.end('Hello World');
|
||||
return;
|
||||
}
|
||||
if (accept && accept.includes('stylesheet')) {
|
||||
res.setHeader('Content-Type', 'text/css');
|
||||
res.end('body { background-color: red; }');
|
||||
return;
|
||||
}
|
||||
res.statusCode = 406;
|
||||
res.end('Not Acceptable');
|
||||
});
|
||||
|
3
src/demo/a.html
Normal file
3
src/demo/a.html
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="title" contenteditable="true">
|
||||
这是一个标题
|
||||
</div>
|
3
src/demo/a.js
Normal file
3
src/demo/a.js
Normal file
@ -0,0 +1,3 @@
|
||||
const onButtonClick = () => {
|
||||
console.log('button clicked');
|
||||
};
|
@ -1,6 +1,10 @@
|
||||
type VividOptions = {
|
||||
pathname?: string;
|
||||
};
|
||||
export class Vivid {
|
||||
pathname: string;
|
||||
constructor() {
|
||||
constructor(opts?: VividOptions) {
|
||||
this.pathname = opts?.pathname || '';
|
||||
console.log('Vivid constructor');
|
||||
}
|
||||
getContent() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user