This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/std/http/server.ts"; | |
const s = serve({ port: 3000 }); | |
for await (const req of s) { | |
req.respond({ body: JSON.stringify({body: "Hello World" })}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Application } from "https://deno.land/x/oak/mod.ts"; | |
const app = new Application(); | |
app.use(ctx => { | |
ctx.response.body = { body: "Hello World" }; | |
}); | |
await app.listen({port: 3000}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serveTLS } from "https://deno.land/std/http/server.ts"; | |
const certFile: string= Deno.env.toObject()["CERT_FILE"]; | |
const keyFile: string= Deno.env.toObject()["KEY_FILE"]; | |
const options = { | |
hostname: "localhost", | |
port: 3000, | |
certFile, | |
keyFile | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/std/http/server.ts"; | |
import { v1 } from "https://deno.land/std/uuid/mod.ts"; | |
const s = serve({ port: 3000 }); | |
const decoder = new TextDecoder(); | |
for await (const req of s) { | |
const body=JSON.parse(decoder.decode(await Deno.readAll(req.body))); | |
const uuids=[]; | |
for(let i=0; i<body.requiredUuids; i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/std/http/server.ts"; | |
const text = await Deno.readTextFile("/var/tmp/sample.json"); | |
const json = JSON.parse(text); | |
const s = serve({ port: 3000 }); | |
for await (const req of s) { | |
req.respond({ status: 200, | |
body: JSON.stringify(json) }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Application } from "https://deno.land/x/oak/mod.ts"; | |
const text = await Deno.readTextFile("/var/tmp/sample.json"); | |
const json = JSON.parse(text); | |
const app = new Application(); | |
app.use((ctx) => { | |
ctx.response.body = json; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"_id": "604179e4d130a49496cc49d0", | |
"index": 0, | |
"guid": "9216f643-8103-4916-8a61-c1c98cc4f2e7", | |
"isActive": false, | |
"balance": "$2,336.88", | |
"picture": "http://placehold.it/32x32", | |
"age": 36, | |
"eyeColor": "green", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/std/http/server.ts"; | |
const get1 = JSON.parse(await Deno.readTextFile("./getData.json")); | |
const get2 = JSON.parse(await Deno.readTextFile("./getData2.json")); | |
const post1 = JSON.parse(await Deno.readTextFile("./postData.json")); | |
const s = serve({ port: 3000 }); | |
for await (const req of s) { | |
console.log(req.url); | |
switch(req.method) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parse } from "https://raw.githubusercontent.com/mayankchoubey/deno-body-parser/main/mod.ts"; | |
import { serve } from "https://deno.land/std/http/server.ts"; | |
const dataStorePath='/private/var/tmp/uploads'; | |
const encoder=new TextEncoder(); | |
const server = serve({ hostname: "0.0.0.0", port: 8080 }); | |
for await (const request of server) { | |
switch(request.url) { | |
case '/uploads': { | |
const body=await parse(request, {saveBodyToFile: true, saveFilePath: dataStorePath}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {PORT, DISK_FILE_PATH} from "./constants.ts"; | |
import {handleRequest} from "./router.ts"; | |
import {getStatus} from "./utils.ts"; | |
if(!await checkSandbox(DISK_FILE_PATH)) { | |
console.error('Required read/write/net access is denied, exiting'); | |
Deno.exit(1); | |
} | |
const listener = Deno.listen({ port: PORT }); |
OlderNewer