Tags

, , , , , ,

Happy Saint Patrick’s Day! It’s a lucky Shamrock day!

Today I met my dear Prof to discuss the Table of Contents for my report and also update her on the possible solutions for the problem of using different web servers. One of the solution was using Reverse Proxy but that would take too much of my time trying to learn something new. I remembered I couldn’t do a question on forward proxy for my Computer Security exam. 😦

Anyway, i stayed in the lab till quite late and I met a group of guys from a startup company, CtrlWorks. They are doing their products in the lab. I find that they are quite helpful and lucky enough, one of the guy, Zen, knows Python very well and is familiar with Raspberry Pi!

I discussed with him regarding the problems that I faced when trying to use 2 web servers in Raspberry Pi to do simple things. He understood the problems immediately and clarified some of my doubts, for example, PHP is indeed can only be put in /var/www and execute by Apache and no way by CherryPy. Also, there is no need to wander off to complicated solution such as using Reverse Proxy (I knew there must be a simpler solution!).

The fact is, the two servers are both on 1 machine- Raspberry Pi, so therefore the web app are basically hosted on the same IP address. Reverse Proxy is normally used for different domain names. Therefore, I can use URL to direct the 2 pages (one at localhost and the other at :8080). With this in mind, I can also embed a page in another page using iframe. This, however may not look nice as the page embedded may not fit nicely in the iframe window. Another possible solution is to embed URL directly as a link. However, absolute URL has to be used because if I write static/icon.png, this will refer to the page that is calling it. Samewise, if I write http://localhost:8080/static/icon.png and display this page from my network laptop, the link will refer to my current laptop’s directory. Therefore, the best way is to use the ip address of Raspberry Pi directly, such as http://192.168.1.109:8080/static/icon.png.

The main problem with my Raspberry Pi is that I can only set a static IP using my room’s router, not my campus’s wireless or LAN. Well, i guess this can’t be helped for now. 🙂

Another thing to consider is cron job where Raspberry Pi can be scheduled to carry out certain tasks such as run a script, reboot, or shutdown. Here are something to look at:
How to Schedule a Job on the Raspberry Pi
Bright Idea: Using Raspberry Pi as a Lamp Timer <– worth trying!
This will satisfy the requirement of "eating the right amount of right pill at the right time!”
I can also start the cherrypy python script at boot up. I have not try this but see this tutorial! Basically it is just this 2 lines:
sudo crontab -e
@reboot python /home/pi/MyScript.py &

Defintely going to add this to my project before it ends. B)

Advertisements