forked from PosGraducao-IFF-2014/trabalho03
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
34 lines (26 loc) · 716 Bytes
/
server.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
28
29
30
31
32
33
34
#-*- encoding: iso-8859-1 -*-
from SOAPpy import SOAPServer
db = 'usuarios.txt'
def login(user):
try:
linhas = open(db,'r').read()
except:
return False
for linha in linhas.split('\n'):
if linha == '':
break
user1,passwd = linha.split('|')
if user['usuario'] == user1 and user['senha'] == passwd:
return True
return False
def registra(user):
if login(user):
return False
conexao = open(db,'a')
conexao.write('%s|%s\n' % (user['usuario'],user['senha']))
conexao.close()
return True
serv = SOAPServer(("localhost", 8080))
serv.registerFunction(login)
serv.registerFunction(registra)
serv.serve_forever()