-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct some ffmpeg and deno server typos
- Loading branch information
Showing
2 changed files
with
19 additions
and
62 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,16 @@ | |
设置文件下载的响应标头([Content-Disposition](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Disposition))就可以实现文件下载。 | ||
|
||
```ts | ||
import { Server } from 'https://deno.land/[email protected]/http/server.ts' | ||
const port = 3000 | ||
const handler = (req: Request) => { | ||
const body = `Your user-agent is:\n\n${req.headers.get('user-agent')}` | ||
|
||
const headers = new Headers({ | ||
'Content-Disposition': 'attachment; filename=text', | ||
}) | ||
if (req.url.endsWith('/file')) | ||
return new Response(body, { headers, status: 200 }) | ||
else return new Response('Not Found', { status: 404 }) | ||
} | ||
|
||
const server = new Server({ handler }) | ||
const listener = Deno.listen({ port }) | ||
|
||
console.log(`Listening on http://localhost:${port}/`) | ||
|
||
await server.serve(listener) | ||
``` | ||
|
||
## 分片下载 | ||
|