addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
let req = '<table>\n'
req += `<tr>\n <td>method</td>\n <td>${request.method}</td>\n</tr>\n`
request.headers.forEach((value, key)=>{
req += `<tr>\n <td>${key}</td>\n <td>${value}</td>\n</tr>\n`
})
req += `<tr>\n <td>body</td>\n <td>${await request.text()}</td>\n</tr>\n`
req += '</table>'
return new Response(req, {
headers: {
'content-type': 'text/html'
}
})
}
1
patrickyoung 2022-07-03 20:19:13 +08:00 via iPhone
https://echo.paw.cloud/
|