Web2py Web App Progress

Today is more fruitful than yesterday.
I found out an awesome function in the web2py Administrative Interface. It is the “New Application Wizard” which will guide you through creating the most basic webpage.

Also, i just realized that there is a much better web2py tutorial here: http://www.web2py.com/books/default/chapter/29/03

So today i created a skeleton of my web app using the application wizard. Then i edited the layout.html, index.html, and default.py. I created default/test.html in accordance to the new function test() created in default.py. Also, i uploaded some pictures.

here is a screenshot:
web2py web app

Click on the light button to turn on

 

wev2py webapp

Flash a “welcome home” and the light turned on

 

here are some codes used:
in controller/default.py

def test():
    import serial
    import time
    response.flash=T(“welcome home!”)

in view/default/index.html

{{extend ‘layout.html’}}

<h1>Welcome to <strong>Cytech Comfort</strong></h1><h2>A new way to control your smart home</h2>

<img src = “/Comfort2/static/images/comfort.jpg” width=”268″ height=”79″>
<br>
<a href = “{{=URL(c=’default’, f=’test’)}}”><img src =”/Comfort2/static/images/off.jpg” width =”75″ height=”75″</a>

in view/default/test.html

{{extend ‘layout.html’}}
<h1>Welcome to <strong>Cytech Comfort</strong></h1><h2>A new way to control your smart home</h2>

<img src = “/Comfort2/static/images/comfort.jpg” width=”268″ height=”79″>
<br>
<img src = “/Comfort2/static/images/on.jpg” width =”75″ height =”75″>
<p>the lights are turned on</p>

However i could not proceed to send the serial commands (which is my main purpose!!) to the device i wish to control through Raspberry Pi.

i added the following codes to def test()
try:
serialport= serial.Serial(“/dev/ttyAMA0”, 9600, timeout=1)
except RuntimeError:
print “Error opening port”
quit()

It issued me a ticket:
<class ‘serial.serialutil.SerialException’> could not open port /dev/ttyAMA0: [Errno 13] Permission denied: ‘/dev/ttyAMA0’

Argh, headache. Sore eyes.😦

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s