From 24f074e1873ffc3f8a1bff80dd2e21cc8b7b9522 Mon Sep 17 00:00:00 2001 From: HipsterBrown Date: Tue, 12 Jan 2016 23:59:22 -0500 Subject: [PATCH] adds intro to webserver tutorial --- webserver.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/webserver.md b/webserver.md index d1110f9..fbfc83f 100644 --- a/webserver.md +++ b/webserver.md @@ -4,16 +4,12 @@
# Build Your Own Internet -
-
+Most web applications are served from remote machines in data centers miles and miles away from the devices that are using them. Through the joys of high-speed internet connections that distance can seem trivial and unnoticeable. -NEW INTRO NEEDED +Because the Tessel 2 runs a full Linux operating systerm, called [OpenWRT](https://openwrt.org), it can run a server and deliver web applications to locally connected devices, quicker than those remote machines due to the immediate distance between the server and devices. -
- -
-By the end of this article, we'll be able to control the Tessel LEDs through a web app served by the Tessel. +By the end of this article, we'll start a server the Tessel and serve a web application that controls the Tessel LEDs through a local network.
@@ -30,7 +26,7 @@ In your command line, make a folder for your Tessel code, then initialize a Tess `t2 init` -Rename the “index.js” file you’ve just created to “ap.js”, then copy and paste the below script over the existing text: +Rename the “index.js” file you’ve just created to “webserver.js”, then copy and paste the below script over the existing text: {% highlight javascript %} // Import the interface to Tessel hardware @@ -58,7 +54,7 @@ Now that our server is in place, let's get our access point set up. In the termi If you haven't read about creating access points yet, check out the [access point tutorial](/ap.html). After connecting to TesselRouter, run the following command in your terminal: -`t2 run ap.js` +`t2 run webserver.js` @@ -158,7 +154,7 @@ Open that file in the browser to see the UI for this web app. Now let's check out the server again to finish up the project. - Replace the code in `ap.js` with the following: + Replace the code in `webserver.js` with the following: {% highlight javascript %} // These two dependencies remain the same @@ -238,9 +234,9 @@ Open that file in the browser to see the UI for this web app. } {% endhighlight %} -In order to make code pushing more efficient, Tessel only pushes the entry point file and its Node dependencies by default. Since index.html is not included in this default push, we'll need to explicitly require it with a .tesselinclude file. +In order to make code pushing more efficient, Tessel only pushes the entry point file and its Node dependencies by default. Since index.html is not included in this default push, we'll need to explicitly require it with a `.tesselinclude` file. -Create a new file called .tesselinclude and copy and paste the following: +Create a new file called `.tesselinclude` and copy and paste the following: {% highlight javascript %} index.html @@ -248,7 +244,7 @@ index.html Finally, let's fire up our server again by running: -`t2 run ap.js` +`t2 run webserver.js` @@ -265,6 +261,7 @@ Here is a demo video:
+The full code for this project can be found in [this repo](https://github.com/HipsterBrown/tessel-router). **Bonus:** Add a way to toggle the red LED as well.