jczic/MicroDNSSrv

Confused on how to get working

Opened this issue · 3 comments

Here is my simple setup:


import network
from microDNSSrv import MicroDNSSrv

ap = network.WLAN(network.AP_IF)
ap.ifconfig(("192.168.4.1", "255.255.255.0", "192.168.0.1", "10.0.0.1"))
ap.active(True)
ap.config(essid = "Simple Test", password = "")

while ap.active() == False: pass

print('Created AP.')
print(ap.ifconfig())

if MicroDNSSrv.Create({"*": ap.ifconfig()[1]}):
    print("yay")
else:
    print("Error to starts MicroDNSSrv...")

print()
print("=======================================================================")
print()

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', 80))
s.listen(5)

with open('index.html', 'r') as f:
    pageHTML = f.read()

while True:
    conn, addr = s.accept()
    print('Got a connection from %s' % str(addr))
    request = conn.recv(1024)
    print(request)
    conn.send(pageHTML)
    conn.close()

however, if I connect to the AP on my phone there is no prompt, and going to some arbitrary website does not redirect me. What am I doing wrong?

I have a very similar setup and the same issue. It's been some years, did you came up with a solution you can share?

I have a very similar setup and the same issue. It's been some years, did you came up with a solution you can share?

Nah unfortunately not; I just have the user navigate to 192.168.4.1 in their browser; pretty annoying ngl

I got it working by refactoring to this solution https://github.com/pimoroni/phew Pretty neat.