2018-11-07 14:28:47 -05:00
|
|
|
# Deno Networking Libraries
|
|
|
|
|
2018-12-12 12:45:57 -05:00
|
|
|
[![Build Status](https://travis-ci.com/denoland/deno_net.svg?branch=master)](https://travis-ci.com/denoland/deno_net)
|
2018-11-07 14:28:47 -05:00
|
|
|
|
|
|
|
Usage:
|
2018-11-08 04:01:20 -05:00
|
|
|
|
2018-11-07 14:28:47 -05:00
|
|
|
```typescript
|
2018-11-08 04:01:20 -05:00
|
|
|
import { serve } from "https://deno.land/x/net/http.ts";
|
|
|
|
const s = serve("0.0.0.0:8000");
|
2018-12-01 02:40:04 -05:00
|
|
|
|
|
|
|
async function main() {
|
|
|
|
for await (const req of s) {
|
|
|
|
req.respond({ body: new TextEncoder().encode("Hello World\n") });
|
|
|
|
}
|
2018-11-08 04:01:20 -05:00
|
|
|
}
|
2018-12-01 02:40:04 -05:00
|
|
|
|
|
|
|
main();
|
2018-11-07 14:28:47 -05:00
|
|
|
```
|
2018-12-11 13:33:52 -05:00
|
|
|
|
|
|
|
## File Server
|
|
|
|
|
|
|
|
A small program for serving local files over HTTP.
|
|
|
|
|
|
|
|
Add the following to your `.bash_profile`
|
|
|
|
```
|
|
|
|
alias file_server="deno https://deno.land/x/net/file_server.ts --allow-net"
|
|
|
|
```
|
|
|
|
|