Page 1 of 1

HOWTO: simple webserver, very simple

Posted: Sun Oct 18, 2015 1:29 am
by cswiger
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.

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

Posted: Sun Oct 18, 2015 3:04 pm
by cswiger
This seems more useful - now to get the temp sensor (ds18b20) working!

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

Re: HOWTO: simple webserver, very simple

Posted: Mon Oct 19, 2015 6:24 pm
by mosi
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

Re: HOWTO: simple webserver, very simple

Posted: Mon Oct 19, 2015 6:37 pm
by RinusW
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.

Re: HOWTO: simple webserver, very simple

Posted: Mon Oct 19, 2015 10:08 pm
by RinusW
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

Re: HOWTO: simple webserver, very simple

Posted: Tue Oct 20, 2015 7:19 am
by danicampora
Very nice RinusW!