Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link to next Webui #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions wifimgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
ap_password = "tayfunulu"
ap_authmode = 3 # WPA2

# If `link_to_next_webui` is set to `True` on the successfully connected page there is a link to the IP of the ESP in the newly connected WiFi.
# This is useful if the ESP shows an other web interface after the WiFiManager, because the user can just click the link and doesn't have to search the new IP of the ESP.
link_to_next_webui = True

NETWORK_PROFILES = 'wifi.dat'

wlan_ap = network.WLAN(network.AP_IF)
Expand Down Expand Up @@ -202,11 +206,19 @@ def handle_configure(client, request):
<span style="color: #ff0000;">
ESP successfully connected to WiFi network %(ssid)s.
</span>
</h1>
</h1>""" % dict(ssid=ssid)
if link_to_next_webui:
response += """\
<p style="text-align: center;">
<a href="http://%(ip)s/">To new Interface [%(ip)s]</a><br>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this. But there is a slight problem now: the new IP is only shown IF link_to_next_webui is True (which only makes sense if you have a http web interface running on the new IP).

If you don't have a http web interface running there, you want to set this to False, but then it also won't display the IP address in plain text - but you might need it, if you run something else on that IP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea: Add an extra variable that if True shows the IP on the success page and leave link_to_next_webui as is. Do you agree ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just always show it, because "why not"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good, too.

(You must be connected to the set network to follow this Link)
</p>
""" % dict(ip=wlan_sta.ifconfig()[0])
response += """\
<br><br>
</center>
</html>
""" % dict(ssid=ssid)
"""
send_response(client, response)
try:
profiles = read_profiles()
Expand Down Expand Up @@ -290,4 +302,3 @@ def start(port=80):
handle_not_found(client, url)
finally:
client.close()