{"id":13801547,"url":"https://github.com/p-doyle/Micropython-DNSServer-Captive-Portal","last_synced_at":"2025-05-13T11:31:21.466Z","repository":{"id":45726209,"uuid":"200664710","full_name":"p-doyle/Micropython-DNSServer-Captive-Portal","owner":"p-doyle","description":"Micropython WiFi AP Captive Portal with DNS and Web Server","archived":false,"fork":false,"pushed_at":"2021-04-17T13:12:34.000Z","size":7,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-18T16:57:35.619Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p-doyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-05T13:50:17.000Z","updated_at":"2024-10-28T15:38:10.000Z","dependencies_parsed_at":"2022-08-26T04:02:02.074Z","dependency_job_id":null,"html_url":"https://github.com/p-doyle/Micropython-DNSServer-Captive-Portal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-doyle%2FMicropython-DNSServer-Captive-Portal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-doyle%2FMicropython-DNSServer-Captive-Portal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-doyle%2FMicropython-DNSServer-Captive-Portal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-doyle%2FMicropython-DNSServer-Captive-Portal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p-doyle","download_url":"https://codeload.github.com/p-doyle/Micropython-DNSServer-Captive-Portal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932879,"owners_count":21986469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:24.174Z","updated_at":"2025-05-13T11:31:19.367Z","avatar_url":"https://github.com/p-doyle.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"# Micropython-DNSServer-Captive-Portal\n\nThis is MicroPython script that creates a Wifi AP with both a DNS and Web Server \nthat act as a 'Captive Portal' by returning its own IP to all DNS queries in\nan attempt to force connecting clients to its Web Server on port 80.  \nWhen connecting from an Android phone it should automatically prompt you to\n 'Sign in to the network', which, if clicked, redirects to the Web Server.  If you try\n browsing to a random domain it *should* redirect you to the web server however\n if the request was HTTPS you will just get a Connected Refused error. \n\nThe code is based on several other examples of a MicroPython Captive Portal that I found\non Github however they were 1+ years old and relied on a single loop to accept connection\nfor both the DNS and Web servers:\n\n- https://github.com/Matt4/micropython-captive-portal-network-setup\n- https://github.com/amora-labs/micropython-captive-portal\n\nMy version uses asyncio to separate the servers and so can be easily extended with\nadditional tasks.  Performance and reliability seem better as well.\n\n\nThis was tested with an ESP32 using the latest firmware from https://micropython.org/download#esp32.  \nThe specific version I tested with was `esp32-20190805-v1.11-187-g00e7fe8ab.bin`.  \nThis should work with an ESP8266 and others as well but I have not fully tested it.\n\n# Initial Setup (ESP32 only)\nSince asyncio is not included in the binary for the ESP32 however it must be installed first.  \nUnless you prefer to build your own binary, this requires that your ESP be able to connect \nto the internet to install.\n-  Open a python terminal with the ESP32 and use the below to connect to your preferred network:\n ```\nimport network\nsta_if = network.WLAN(network.STA_IF)\nsta_if.active(True)\nsta_if.connect('yourssid', 'yourpw')\n```\n- Then run:\n```\nimport upip\nupip.install('micropython-uasyncio')\n```\n\n# To Do\nI'd like to be able to serve HTTPS as well, which would make this a lot more useful however \nI was unable to get the Micropython example code working https://github.com/micropython/micropython/blob/master/examples/network/http_server_ssl.py","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-doyle%2FMicropython-DNSServer-Captive-Portal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp-doyle%2FMicropython-DNSServer-Captive-Portal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-doyle%2FMicropython-DNSServer-Captive-Portal/lists"}