Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://capture.dropbox.com/bkF5UoX4ybyFx3Ja
- import network
- import socket
- # Set up access point
- ap = network.WLAN(network.AP_IF)
- #ap.config(essid='PicoW_AP',password='PASSWORD') #Pb added password
- ap.config(essid='NAME2',password='PASSWORD') #Pb added password
- ap.active(True)
- # Wait for connection
- while not ap.isconnected():
- pass
- print('AP Mode Is Active, You can Now Connect')
- print('IP Address To Connect to::', ap.ifconfig()[0])
- # Set up socket
- addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
- s = socket.socket()
- s.bind(addr)
- s.listen(1)
- print('Listening on', addr)
- while True:
- cl, addr = s.accept()
- print('Got a connection from', addr)
- request = cl.recv(1024)
- print('Content received by Pico =', request)
- # Attempt to read the log.csv file
- try:
- with open('log.csv', 'r') as file:
- log_data = file.read()
- except OSError:
- log_data = "Error: log.csv file not found."
- # Send a proper HTTP response with the CSV data
- response = """\
- HTTP/1.1 200 OK
- Content-Type: text/csv
- Content-Disposition: attachment; filename="log.csv"
- Content-Length: {}
- {}
- """.format(len(log_data), log_data)
- cl.send(response)
- cl.close()
Advertisement
Advertisement