Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import socket
import time
def Main():
#Give ChatBot server an IP address and port
host = "127.0.0.1"
port = 50036
#Create Socket and bind server to socket
thisSocket = socket.socket()
thisSocket.bind((host,port))
#Listen for clients
thisSocket.listen(1)
#Connect to client
conn, addr = thisSocket.accept()
#print Connect ip address
print ("The Connection ip is : " + str(addr))
#Repear forever
saudations = "Hi user, i am Foodie and am here to help you to decide what will be your meal"
conn.send(saudations.encode())
while True:
#Receive info from client
receiveMess = conn.recv(1024).decode()
#if no info from client end loop
if not receiveMess:
break
#Print info from client
print ("Message from User to Chatbot : " + str(receiveMess))
#set return message
checkUser = "Hi user, are you already registered ?"
conn.send(checkUser.encode())
receiveCheckUser = conn.recv(1024).decode()
if receiveCheckUser == "y" or receiveCheckUser == "Y":
#implement login form
username = "hi carlos"
conn.send(checkUser.encode())
else:
createAcc = "do you want to create an account ?"
conn.send(createAcc.encode())
conn.close()
if __name__ == '__main__':
Main()