<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Webserver - Access point]]></title><description><![CDATA[<p dir="auto">Hi All,<br />
Where can I find a good functional example of a web server that acts as an access point?<br />
If possible I would like to store the web pages in the file system.<br />
It should be easy to add routes.<br />
It will be awesome if provision is made for dynamic data<br />
Any guidance will be appreciated.</p>
]]></description><link>https://forum.pycom.io/topic/6170/webserver-access-point</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 10:38:21 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/6170.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Jul 2020 11:46:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Webserver - Access point on Tue, 21 Jul 2020 11:46:10 GMT]]></title><description><![CDATA[<p dir="auto">Hi All,<br />
Where can I find a good functional example of a web server that acts as an access point?<br />
If possible I would like to store the web pages in the file system.<br />
It should be easy to add routes.<br />
It will be awesome if provision is made for dynamic data<br />
Any guidance will be appreciated.</p>
]]></description><link>https://forum.pycom.io/post/33548</link><guid isPermaLink="true">https://forum.pycom.io/post/33548</guid><dc:creator><![CDATA[EmbeddedGuy]]></dc:creator><pubDate>Tue, 21 Jul 2020 11:46:10 GMT</pubDate></item><item><title><![CDATA[Reply to Webserver - Access point on Tue, 21 Jul 2020 11:48:10 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I made this example a while ago. Some adapting is required but I believe you should be able to make it work!<br />
Best,</p>
<pre><code>import usocket
import _thread
import time
from network import WLAN
import pycom

availablecolor = 0x001100
connectioncolor = 0x110000

# Thread for handling a client
def client_thread(clientsocket,n):
    # Receive maxium of 12 bytes from the client
    r = clientsocket.recv(4096)

    # If recv() returns with 0 the other end closed the connection
    if len(r) == 0:
        clientsocket.close()
        return
    else:
        # Do something wth the received data...
        print(&quot;Received: {}&quot;.format(str(r))) #uncomment this line to view the HTTP request

    http = &quot;HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection:close \r\n\r\n&quot; #HTTP response
    
    if &quot;GET / &quot; in str(r):
        #this is a get response for the page   
        # Sends back some data
        clientsocket.send(http + &quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt; You are connection &quot;+ str(n) + &quot;&lt;/h1&gt;&lt;br&gt; Your browser will send multiple requests &lt;br&gt; &lt;a href='/hello'&gt; hello!&lt;/a&gt;&lt;br&gt;&lt;a href='/color'&gt;change led color!&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;&quot;)
    elif &quot;GET /hello &quot;in str(r):
        
        clientsocket.send(http + &quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt; Hello to you too! &lt;/h1&gt;&lt;br&gt; &lt;a href='/'&gt; go back &lt;/a&gt;&lt;/body&gt;&lt;/html&gt;&quot;)
    elif &quot;GET /color&quot; in str(r):
        pycom.rgbled(0xFFFFFF)
        clientsocket.send(http + &quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt; You are connection &quot;+ str(n) + &quot;&lt;/h1&gt;&lt;br&gt; Your browser will send multiple requests &lt;br&gt; &lt;a href='/hello'&gt; hello!&lt;/a&gt;&lt;br&gt;&lt;a href='/color'&gt;change led color!&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;&quot;)

    # Close the socket and terminate the thread

    clientsocket.close()
    pycom.rgbled(connectioncolor)
    time.sleep_ms(500)
    pycom.rgbled(availablecolor)  

time.sleep(1)
wifi = WLAN()
wifi.init(mode=WLAN.AP, ssid=&quot;hello&quot;, auth=None, channel=1)
print(&quot;WiFi is up!&quot;)
time.sleep(1)
pycom.heartbeat(False)
pycom.rgbled(availablecolor)

# Set up server socket
serversocket = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
serversocket.setsockopt(usocket.SOL_SOCKET, usocket.SO_REUSEADDR, 1)
serversocket.bind((&quot;192.168.4.1&quot;, 80))

# Accept maximum of 5 connections at the same time
serversocket.listen(5)

# Unique data to send back
c = 1
while True:
    # Accept the connection of the clients
    (clientsocket, address) = serversocket.accept()
    # Start a new thread to handle the client
    _thread.start_new_thread(client_thread, (clientsocket, c))
    c = c+1
serversocket.close()
</code></pre>
]]></description><link>https://forum.pycom.io/post/33549</link><guid isPermaLink="true">https://forum.pycom.io/post/33549</guid><dc:creator><![CDATA[Gijs]]></dc:creator><pubDate>Tue, 21 Jul 2020 11:48:10 GMT</pubDate></item><item><title><![CDATA[Reply to Webserver - Access point on Tue, 21 Jul 2020 14:21:55 GMT]]></title><description><![CDATA[<p dir="auto">We have been using <a href="https://github.com/jczic/MicroWebSrv2" target="_blank" rel="noopener noreferrer nofollow">MicroWebSrv2</a> that allows you to serve any files needed.  Also supports a custom file type: pyhtml that you can embed python code, it will be first processed by the web engine, then produce the actual html file finally it will serve it.</p>
]]></description><link>https://forum.pycom.io/post/33551</link><guid isPermaLink="true">https://forum.pycom.io/post/33551</guid><dc:creator><![CDATA[nftylitak]]></dc:creator><pubDate>Tue, 21 Jul 2020 14:21:55 GMT</pubDate></item><item><title><![CDATA[Reply to Webserver - Access point on Wed, 22 Jul 2020 11:16:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/6311">@Gijs</a> Thnx for the feedback. I will definitely look into it. It looks simple enough to do an interface for setting network credentials etc. Much appreciated.</p>
]]></description><link>https://forum.pycom.io/post/33592</link><guid isPermaLink="true">https://forum.pycom.io/post/33592</guid><dc:creator><![CDATA[EmbeddedGuy]]></dc:creator><pubDate>Wed, 22 Jul 2020 11:16:31 GMT</pubDate></item><item><title><![CDATA[Reply to Webserver - Access point on Wed, 22 Jul 2020 11:30:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/5533">@nftylitak</a> Thnx for the feedback. I did see this. I think it is approx 150K in size, a bit big but comes with a lot of functionality.<br />
Not sure how to get started with it. THNX!!</p>
]]></description><link>https://forum.pycom.io/post/33593</link><guid isPermaLink="true">https://forum.pycom.io/post/33593</guid><dc:creator><![CDATA[EmbeddedGuy]]></dc:creator><pubDate>Wed, 22 Jul 2020 11:30:08 GMT</pubDate></item></channel></rss>