how to host a local python server

Solutions on MaxInterview for how to host a local python server by the best coders in the world

showing results for - "how to host a local python server"
Riccardo
02 Mar 2020
1________________________________________________________________________________
2
3
4
5--------------------------------------------------------------------------------
6THIS IS HOW TO HOST THE SERVER :
7--------------------------------------------------------------------------------
8import time
9import sys
10import socket
11import os
12
13s = socket.socket()
14host = socket.gethostname()
15print(host)
16port = 8080
17s.bind((host,port))
18print("")
19print("Waiting for a device to connect...")
20print("")
21s.listen(5)
22conn, addr = s.accept()
23print (addr, " - is connected")
24print ("")
25
26
27
28
29
30--------------------------------------------------------------------------------
31THIS IS HOW TO MAKE THE CLIENT FOR THE SERVER :
32--------------------------------------------------------------------------------
33import time
34import sys
35import socket
36import os
37
38s = socket.socket()
39host = input("Type here hostname : ")
40port = 8080
41s.connect((host,port))
42print("")
43print("connected to server")
44print("")
45
46
47
48________________________________________________________________________________
49
50
51