applied pycharm "reformat file"

fixes:

- indentation: tabs -> 4 spaces
- spaces around operators
- other pep8 issues
pull/3/head
Thomas Waldmann 2017-12-11 14:38:41 +01:00
rodzic 582cc2acbc
commit f11fcbf606
2 zmienionych plików z 209 dodań i 205 usunięć

Wyświetl plik

@ -1,8 +1,10 @@
import network
import networkconfig
import time
wlan_sta = network.WLAN(network.STA_IF)
def do_connect(ntwrk_ssid, netwrk_pass):
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
@ -21,6 +23,7 @@ def do_connect(ntwrk_ssid, netwrk_pass):
print('\nProblem. Not Connected to :' + ntwrk_ssid)
return (False)
def check_connection():
global wlan_sta
# Firstly check is there any connection
@ -61,6 +64,7 @@ def check_connection ():
return (False)
if check_connection():
# Main Code is here
@ -70,8 +74,3 @@ if check_connection ():
else:
print("There is something wrong")

Wyświetl plik

@ -12,6 +12,7 @@ ssid_password = "tayfunulu"
server_socket = None
def do_connect(ntwrk_ssid, netwrk_pass):
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
@ -31,6 +32,7 @@ def do_connect(ntwrk_ssid, netwrk_pass):
print('\nProblem. Not Connected to :' + ntwrk_ssid)
return (False)
def send_response(client, payload, status_code=200):
client.sendall("HTTP/1.0 {} OK\r\n".format(status_code))
client.sendall("Content-Type: text/html\r\n")
@ -40,6 +42,7 @@ def send_response(client, payload, status_code=200):
if len(payload) > 0:
client.sendall(payload)
def handle_root(client):
global wlan_sta
response_header = """
@ -76,6 +79,7 @@ def handle_root(client):
"""
send_response(client, response_header + response_variable + response_footer)
def handle_configure(client, request):
match = ure.search("ssid=([^&]*)&password=(.*)", request)
@ -90,7 +94,6 @@ def handle_configure(client, request):
ssid = match.group(1).replace("%3F", "?").replace("%21", "!")
password = match.group(2).replace("%3F", "?").replace("%21", "!")
if len(ssid) == 0:
send_response(client, "SSID must be provided", status_code=400)
return (False)
@ -129,15 +132,18 @@ def handle_configure(client, request):
send_response(client, response_footer)
return (False)
def handle_not_found(client, url):
send_response(client, "Path not found: {}".format(url), status_code=404)
def stop():
global server_socket
if server_socket:
server_socket.close()
def start(port=80):
addr = socket.getaddrinfo('0.0.0.0', port)[0][-1]
@ -153,7 +159,6 @@ def start(port=80):
wlan_ap.config(essid=ssid_name, password=ssid_password)
server_socket = socket.socket()
server_socket.bind(addr)
server_socket.listen(1)