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

replacement of ipv4_address with conditional #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
7 changes: 4 additions & 3 deletions wsgiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def start(self):
invoked on receiving an incoming request.
"""
self._server_sock = pool.socket(pool.AF_INET, pool.SOCK_STREAM)
self._server_sock.bind((repr(wifi.radio.ipv4_address), self.port))
self._server_sock.bind((repr(wifi.radio.ipv4_address if wifi.radio.ipv4_address else wifi.radio.ipv4_address_ap), self.port))
self._server_sock.listen(1)

# if self._debug:
Expand All @@ -170,7 +170,8 @@ def pretty_ip(self):
"""
Return a "pretty" representation of the current local IP.
"""
return f"http://{wifi.radio.ipv4_address}:{self.port}"
ipaddress = wifi.radio.ipv4_address if wifi.radio.ipv4_address else wifi.radio.ipv4_address_ap
return f"http://{ipaddress}:{self.port}"

def update_poll(self):
"""
Expand Down Expand Up @@ -275,7 +276,7 @@ def _get_environ(self, client):

env["REQUEST_METHOD"] = method
env["SCRIPT_NAME"] = ""
env["SERVER_NAME"] = str(wifi.radio.ipv4_address)
env["SERVER_NAME"] = str(wifi.radio.ipv4_address if wifi.radio.ipv4_address else wifi.radio.ipv4_address_ap)
env["SERVER_PROTOCOL"] = ver
env["SERVER_PORT"] = self.port
if path.find("?") >= 0:
Expand Down