Created
November 24, 2022 14:29
-
-
Save AXKuhta/0685e887a5a27e14032729277624a728 to your computer and use it in GitHub Desktop.
Nucleo F746ZG Micropython HTTP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import network | |
import socket | |
x = network.LAN() | |
x.active(True) | |
print(x.ifconfig()) | |
ListenPort = 80 | |
Host = '' | |
MainSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
MainSocket.bind((Host, ListenPort)) | |
MainSocket.listen(0) | |
while True: | |
print("Waiting for connections...") | |
Client, Addr = MainSocket.accept() | |
print("New connection!") | |
while True: | |
line = Client.readline() | |
if line == b"\r\n": | |
break | |
print(line) | |
Client.send(b"HTTP/1.0 200 OK\r\n") | |
Client.send(b"Content-Length: 5\r\n") | |
Client.send(b"\r\n") | |
Client.send(b"Hello") | |
Client.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment