· 7 years ago · Oct 27, 2018, 03:16 PM
1from flask import request
2from flask import FLASK
3import socket
4
5import time
6
7class Client:
8 __socket = 0
9 def __init__(self, hostage, port, timeout = None):
10 self.__socket = socket.create_connection((hostage, port), timeout)
11
12 def receive(self, name):
13 if request.method == "GET":
14 login = request.form['login']
15 email = request.form['email']
16 password = request.form['password']
17 phone = request.form['phone']
18 fname = request.form['fname']
19 lname = request.form['lname']
20 if len(phone) <= 12 and len(phone) >= 11:
21 incorrect_input()
22 return False
23 self.__socket.sendall((' '.join(login, email, phone, fname,
24 lname, password)).encode('utf-8')
25 main_server_answer = (self.__socket.recv(1024)).decode('utf-8')
26
27 def incorrect_input():
28 print("Incorrect")
29
30 def correctness_check(email, phone):
31 first = True
32 for cur_elem in phone:
33 if (not first and (not('0' <= cur_elem and cur_elem <= '9') or cur_elem == '+')):
34 incorrect_input()
35 return False;
36 first = False
37
38 domens = ['mail.ru', 'yandex.ru', 'bk.ru', 'list.ru', 'gmail.com']
39
40 special_symb = -1
41 for i in range(len(email)):
42 if ('0' <= email[i] and email[i] <= '9') or\
43 ('A' <= email[i] and 'Z' <= email[i]) or\
44 ('a' <= email[i] and 'z' <= email[i]) or\
45 (email[i] in {'!', '#', '$', '%', '&',
46 '*', '+', '-', '/', '=', '?', '^', '_', '`', '{', '|', '}', '~'}):
47 pass
48 elif email[i] == '@':
49 special_symb = i + 1
50 break
51 else:
52 incorrect_input()
53 return False
54 if special_symb <= 0 or email[special_symb:len(email)] not in domens:
55 incorrect_input()
56 return False
57 return True
58
59 def send(self, data[]):
60 pass