2018-11-07 14:28:47 -05:00
|
|
|
# Deno Networking Libraries
|
|
|
|
|
|
|
|
[![Build Status](https://travis-ci.com/denoland/net.svg?branch=master)](https://travis-ci.com/denoland/net)
|
|
|
|
|
|
|
|
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"
|
|
|
|
```
|
|
|
|
|