import network
import socket
from time import time


station = network.WLAN(network.STA_IF) # Konfiguration des Network-Interfaces
station.active(True)
station.connect('mipa_devolo', 'asdfghjkl1234') # hier Ihre Wlan-Daten eintragen!
time0 = time()
while (station.isconnected() == False) and (time() - time0 < 5):
  pass

if station.isconnected():
  print('Wlan connected')
  print(station.ifconfig()) # zur Information  
  server_addr = ('g-heinrichs.de', 80)
  client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  client.connect(server_addr)
  print('Socket connected')
  request = 'GET /hallo.txt HTTP/1.1\r\nHost:g-heinrichs.de\r\n\r\n'
  client.send(request)
  data = client.recv(1024) # max. Anz. der Bytes
  print(str(data,'UTF-8'))
  print('')
  client.close()
  print('Socket closed')
  
station.active(False)
print('Wlan deactivated')







