Web report II

14 downloads 266 Views 340KB Size Report
NOTE: Please do not open the python script in Windows, as that will make it ... WSN website and Facebook app (2011: Facebook is a 1 point BONUS!).
Exercise #4: WSN website and Facebook application Introduction This exercise continues straight from where we got in Exercise 2: Web report. Make sure that the nodes you’re going to use in this exercise have their “Feed visibility” attribute set to “show” in WSNExerciseUI. NOTE: Please do not open the python script in Windows, as that will make it un-runnable. If you modified your script in Windows in Ex2, please download the demo script from the course webpage again.

WSN website and Facebook app (2011: Facebook is a 1 point BONUS!) Follow the instructions below to set up your own website with dynamic content from sensor network and to make the website into a Facebook application. Setting up the webpage Log into Lintula, go to your home directory and make a new directory named ”public_html” if you don’t already have it. You need to set the right privileges with chmod -R a+r ~/public_html You also need to give referencing rights to everybody for your home directory, so that Lintula www server is allowed to read the files: chmod o+x ~ Create a webpage in your ~/public_html directory. If you are completely new to HTML try Google, there’s a huge amount of basic HTML tutorials on the web. To get dynamic WSN data to your page use the Python script from the earlier exercise. The Python script will work as a CGI-script, which means that its output is displayed on a webpage. You need to create a new directory for CGI-scripts in your home directory called ”cgi-bin”. Copy the Python script from earlier exercise there and set the right privileges with chmod 755 ~/cgi-bin/demo.cgi To call the script from your html code use include virtual SSI-directive: Edit the directive so that it points to your own CGI script. Obviously just change the part ”USERNAME” to be same that you logged in with. Also, be sure that you save your page as .shtml instead of just .html or the SSI-directive will just be ignored as a HTML comment.

After this, you need to edit your script so that it works as a valid CGI script. First of all, you have to define the python interpreter path in your script. So, put #!/usr/local/bin/python as the first line in your file. Then you have to make sure that the first thing your script actually prints is what a CGI script should print. Try for example Googling for “cgi script headers” to see what and why. (You can run your script from URL http://www.cs.tut.fi/cgi-bin/rund/USERNAME/demo.cgi to get debug information about your script if it’s not working, and if you change the “rund” part to just “run” you should see only the output of your script) Now you should be able to point your web browser to www.cs.tut.fi/~USERNAME/YOURPAGENAME.shtml and see the script in action. More info about own web pages in Lintula can be found at www.cs.tut.fi/lintula/ohjeet/www-palvelu (some of the info is available also in English, but not all. If you have complaints about that, please contact Lintula administration instead of the course staff. Feel free to ask help, however!!!) Viewing your website as Facebook application (this is a bonus! Not compulsory!) To earn one extra bonus point, someone from your group needs to have a Facebook account (www.facebook.com). If not, or if you do not wish to use your own account for this exercise for some reason, you need to set up a new one. Next, join “Facebook Developers” so that you can make your own Facebook applications. You can find it here. After joining go to the Developers page and there click the “create application” link (found in upper right area). Unfortunately, Facebook requires a confirmed account for developers. Thus, you must either give your mobile phone number or credit card number to confirm your account. If you want the bonus point, use your own judgment about giving such information for a large American mega-corporation. There’s plenty of information you can include about your application, but most of them are optional. The minimum you need to do to get your website into Facebook is: -

Choose unique name for your app. Choose Canvas Page. This is the URL of your Facebook application. As you’ll notice only the last part of the address can be customized. Set Canvas URL to point to the webpage you created in Lintula earlier in this exercise. Add a question mark (?) after the URL, as Facebook requires it.

Now you should be able to point your browser to the specified “Canvas Page” URL and see your website viewed as a Facebook application. Edit the CGI script to do something useful (This is compulsory!) Choose a node that your script will monitor. Make the program display “traffic light” information about the node’s data in your webpage. The main point is that you abstract the sensor network and other interfaces away and the end-user sees only very simple information. You could, for example, have red/yellow/green “light” in your page depending on the room temperature or carbon dioxide

concentration. Or you could have thumbs up/down picture in the page telling if your indoor plant needs watering. Bonus points Remember that this exercise has as many as three (3) bonus points available. Bonuses are awarded to solutions that are innovative, well done and implement more than just the required basic functionality. For example, there’s a lot more things you can make a Facebook app do that are not covered in this assignment.

Return Return a report that includes -

URL to your (working) application (and to the Facebook app, if you want the extra point) Your CGI script as attachment Description about what and why your app does and how it was implemented Short description of potential problems/ideas How much time you spent on this task

Return the report by e-mail to [email protected] if you are on course TKT-2301 or [email protected] if you are on course TKT-2307. Remember to include your group number in your report. Use following subject format (replace xx with your group number): TKT2301-Gxx-Exx or TKT2307-Gxx-Exx.