sobre web.py
Publicado por kanzer (1 intervención) el 01/06/2015 20:14:53
Soy aprendiz de python y tengo el siguiente codigo:
Solo que a cada rato se cae, no se como ver logs y preferiria cambiarlo a web.py
Alguna sugerencia
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python2.7
import BaseHTTPServer
import urlparse
import os
HOST_NAME = ''
PORT_NUMBER=8000
postVars = ''
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(s):
print("Just received a GET request")
s.send_response(200)
s.send_header("Content-type", "text/html")
s.end_headers()
s.wfile.write('Hello world')
return
def do_POST(s):
global postVars
s.send_response(200)
s.send_header("Content-type", "text/html")
s.end_headers()
varLen = int(s.headers['Content-Length'])
postVars = s.rfile.read(varLen)
#print postVars
server_class = BaseHTTPServer.HTTPServer
httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler)
while True:
try:
httpd.handle_request()
except KeyboardInterrupt:
pass
#print postVars
qs = dict( (k, v if len(v)>1 else v[0] )
for k, v in urlparse.parse_qs(postVars).iteritems() )
pase = qs['pase']
dominio = qs['dominio']
usuario = qs['usuario']
email = usuario + "@" + dominio
print email
if email in open('/etc/mail/vrecipients').read():
print "Usuario ya existe!!"
else:
os.system("/etc/mail/createuser.sh %s %s %s" % (pase,usuario,dominio))
Alguna sugerencia
Valora esta pregunta


0