|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 6 | + <meta http-equiv="X-UA-Compatible" content="ie=edge" /> |
| 7 | + <link rel="stylesheet" href="./style.css" /> |
| 8 | + <title>Hello Twilio Serverless!</title> |
| 9 | + </head> |
| 10 | + <body> |
| 11 | + <header><h1>Hello Twilio Serverless!</h1></header> |
| 12 | + |
| 13 | + <main> |
| 14 | + <p> |
| 15 | + <strong>Congratulations</strong> you just started a new Twilio |
| 16 | + Serverless project. |
| 17 | + </p> |
| 18 | + |
| 19 | + <h2>Assets</h2> |
| 20 | + <p> |
| 21 | + Assets are static files, like HTML, CSS, JavaScript, images or audio |
| 22 | + files. |
| 23 | + </p> |
| 24 | + |
| 25 | + <p> |
| 26 | + This HTML page is an example of a <strong>public</strong> asset, you can |
| 27 | + access this by loading it in the browser. The HTML also refers to |
| 28 | + another public asset for CSS styles. |
| 29 | + </p> |
| 30 | + <p> |
| 31 | + You can also have <strong>private</strong> assets, there is an example |
| 32 | + private asset called <code>message.private.js</code> in the |
| 33 | + <code>/assets</code> directory. This file cannot be loaded in the |
| 34 | + browser, but you can load it as part of a function by finding its path |
| 35 | + using <code>Runtime.getAssets()</code> and then requiring the file. |
| 36 | + There is an example of this in |
| 37 | + <code>/functions/private-message.protected.js</code>. |
| 38 | + </p> |
| 39 | + |
| 40 | + <h2>Functions</h2> |
| 41 | + <p> |
| 42 | + Functions are JavaScript files that will respond to incoming HTTP |
| 43 | + requests. There are <strong>public</strong> and |
| 44 | + <strong>protected</strong> functions. |
| 45 | + </p> |
| 46 | + |
| 47 | + <p> |
| 48 | + <strong>Public</strong> functions respond to all HTTP requests. There is |
| 49 | + an example of a public function in |
| 50 | + <code>/functions/hello-world.js</code>. |
| 51 | + </p> |
| 52 | + |
| 53 | + <p> |
| 54 | + <strong>Protected</strong> functions will only respond to HTTP requests |
| 55 | + with a valid Twilio signature in the header. You can read more about |
| 56 | + <a href="https://www.twilio.com/docs/usage/security#validating-requests" |
| 57 | + >validating requests from Twilio in the documentation</a |
| 58 | + >. There is an example of a protected function in |
| 59 | + <code>/functions/private-message.protected.js</code> |
| 60 | + </p> |
| 61 | + |
| 62 | + <h2>twilio-run</h2> |
| 63 | + |
| 64 | + <p> |
| 65 | + Functions and assets are served, deployed and debugged using |
| 66 | + <a href="https://github.com/twilio-labs/twilio-run" |
| 67 | + ><code>twilio-run</code></a |
| 68 | + >. You can serve the project locally with the command |
| 69 | + <code>npm start</code> which is really running |
| 70 | + <code>twilio-run --env</code> under the hood. If you want to see what |
| 71 | + else you can do with <code>twilio-run</code> enter |
| 72 | + <code>npx twilio-run --help</code> on the command line or check out |
| 73 | + <a href="https://github.com/twilio-labs/twilio-run" |
| 74 | + >the project documentation on GitHub</a |
| 75 | + >. |
| 76 | + </p> |
| 77 | + </main> |
| 78 | + |
| 79 | + <footer> |
| 80 | + <p> |
| 81 | + Made with 💖 by your friends at |
| 82 | + <a href="https://www.twilio.com">Twilio</a> |
| 83 | + </p> |
| 84 | + </footer> |
| 85 | + </body> |
| 86 | +</html> |
0 commit comments