forked from Luiz-Gomess/ContratAe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clientePY.py
28 lines (21 loc) · 848 Bytes
/
clientePY.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pickle
import socket
import time
import os
HOST = '127.0.0.1'
PORT = 5000
servidor = (HOST, PORT)
cliente_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
cliente_socket.connect(servidor)
protocol_msg = "POST" # -> definindo a flag do protocolo.
cliente_socket.send(protocol_msg.encode('utf-8'))
data_cliente = {}
data_cliente["nome"] = input("Digite o nome: ")
data_cliente["email"] = input("Digite o email: ")
# data_cliente["id"] = int(time.time()) # -> Retorna um unixtimestamp para o ID
data_cliente["id"] = os.getpid() # -> Retorna um unixtimestamp para o ID
data_cliente["type"] = input("Voce é candidato ou recrutador: ").lower()
data_cliente["senha"] = "1234"
# -> usando o pickle para transformar em binario
data_cliente = pickle.dumps(data_cliente)
cliente_socket.send(data_cliente) # -> enviando via sockets