mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 22:08:02 +00:00
update deno example
This commit is contained in:
parent
fb81affdc3
commit
58d3e74c02
6 changed files with 24 additions and 5650 deletions
6
deno/.vscode/settings.json
vendored
Normal file
6
deno/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"deno.enable": true,
|
||||
"deno.lint": true,
|
||||
"deno.unstable": false,
|
||||
"deno.importMap": "importmap.json"
|
||||
}
|
7
deno/app.ts
Normal file
7
deno/app.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { Handler, ServeInit, serve } from "http/server.ts";
|
||||
|
||||
const handler: Handler = () => new Response("Hello World\n");
|
||||
const options: ServeInit = { addr: "localhost:8080" };
|
||||
|
||||
serve(handler, options);
|
||||
console.log(`Server running on http://${options.addr}`);
|
5
deno/importmap.json
Normal file
5
deno/importmap.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"imports": {
|
||||
"http/": "https://deno.land/std@0.115.1/http/"
|
||||
}
|
||||
}
|
6
deno/scripts.yml
Normal file
6
deno/scripts.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
# yaml-language-server: $schema=https://deno.land/x/denon@2.4.10/schema.json
|
||||
importmap: importmap.json
|
||||
scripts:
|
||||
start:
|
||||
cmd: "deno run app.ts"
|
||||
allow: [net]
|
File diff suppressed because it is too large
Load diff
|
@ -1,10 +0,0 @@
|
|||
import { serve } from "https://deno.land/std@0.56.0/http/server.ts";
|
||||
|
||||
async function main() {
|
||||
const port = 8000;
|
||||
console.log(`http://localhost:${port}/`);
|
||||
for await (const req of serve({ port })) {
|
||||
req.respond({ body: "Hello World\n" });
|
||||
}
|
||||
}
|
||||
main();
|
Loading…
Add table
Reference in a new issue