HOWTO: simple webserver, very simple

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
cswiger
Posts: 13
Joined: Fri Oct 16, 2015 9:51 pm

HOWTO: simple webserver, very simple

Post by cswiger » Sun Oct 18, 2015 1:29 am

Played with this today - based on https://github.com/micropython/micropyt ... -server.py

https://github.com/cswiger/wipy/blob/ma ... -server.py

playing with http-client.py seems more useful for sending data outside actually.

cswiger
Posts: 13
Joined: Fri Oct 16, 2015 9:51 pm

Re: HOWTO: easy http client for publishing rest api data

Post by cswiger » Sun Oct 18, 2015 3:04 pm

This seems more useful - now to get the temp sensor (ds18b20) working!

https://github.com/cswiger/wipy/blob/ma ... -client.py

mosi
Posts: 28
Joined: Tue Oct 07, 2014 12:07 am

Re: HOWTO: simple webserver, very simple

Post by mosi » Mon Oct 19, 2015 6:24 pm

Have you tried this on actual CC3200 architecture or just unix version?

There seems to be an error with this line:
any help appreciated.

Code: Select all

>>> s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: no such attribute
>>> s.set
setsockopt      settimeout      setblocking
>>> s.setsockopt(socket.SOCK_
SOCK_STREAM     SOCK_DGRAM      SOCK_RAW
>>> s.setsockopt(socket.
__name__        socket          getaddrinfo     error
timeout         AF_INET         AF_INET6        SOCK_STREAM
SOCK_DGRAM      SOCK_RAW        IPPROTO_SEC     IPPROTO_TCP
IPPROTO_UDP     IPPROTO_RAW

RinusW
Posts: 9
Joined: Wed Oct 07, 2015 10:51 am

Re: HOWTO: simple webserver, very simple

Post by RinusW » Mon Oct 19, 2015 6:37 pm

As far as I can tell, setsockopt() is not completely implemented yet. But for your first experiments, you don't need this function. So, just leave it out.
His second reference https://github.com/cswiger/wipy/blob/ma ... -server.py don't use this function either.

RinusW
Posts: 9
Joined: Wed Oct 07, 2015 10:51 am

Re: HOWTO: simple webserver, very simple

Post by RinusW » Mon Oct 19, 2015 10:08 pm

I wrote a simple webserver with some Ajax functionality.
When accessing with a (modern) browser the server will send an html file to the browser, resulting in the next screen:
https://github.com/RinusW/WiPy/blob/mas ... ebpage.jpg
The 2 input elements communicate their value using Ajax to the server, the server responds with sending the value back to the browser and is used in the browser to update the value of the other input element.
So, adjusting the slider will result in a change of the value above the slider. And changing the number value will result in a new position of the slider. And this coupling is through the web server.
You find the python code and the html page with embedded javascript here:
https://github.com/RinusW/WiPy/tree/master/AiCWebserver

Btw: the webserver uses an endless loop and blocking calls. You can terminate the server by typing CTRL-C

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: HOWTO: simple webserver, very simple

Post by danicampora » Tue Oct 20, 2015 7:19 am

Very nice RinusW!

Post Reply