import socket
import thread
def run(clientsock,addr):
"Burada kesinlikle karşılaştırma, sorgu veya koşul eklemeyinz(yanıt süreniz uzar)"
try:
a=clientsock.recv(BUFF)
status = '200 OK'
clientsock.send('HTTP/1.0 200 OK\r\n')
clientsock.send('Content-type:application/x-bzip2\r\n')
clientsock.send('Access-Control-Allow-Origin:*\r\n\r\n')
clientsock.send(sıkılştırılmış_bz2_json_içerik)
clientsock.close()
except Exception,e:print e
class _main(): #CGI+ALL THREAD
def run(self,salla):
ADDR = (HOST, PORT)
serversock = socket(AF_INET, SOCK_STREAM)
serversock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
serversock.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
serversock.bind(ADDR)
serversock.listen(10)
While True :
try:
#Burada kime yetki verecekseniz ona göre thread açın
thread.start_new_thread(run, (clientsock, addr))
except Exception,e:print "thr start error :",e
if __name__ == "__main__":
ma_in = _main()
thread.start_new_thread(ma_in.run,(None,))
import thread
def run(clientsock,addr):
"Burada kesinlikle karşılaştırma, sorgu veya koşul eklemeyinz(yanıt süreniz uzar)"
try:
a=clientsock.recv(BUFF)
status = '200 OK'
clientsock.send('HTTP/1.0 200 OK\r\n')
clientsock.send('Content-type:application/x-bzip2\r\n')
clientsock.send('Access-Control-Allow-Origin:*\r\n\r\n')
clientsock.send(sıkılştırılmış_bz2_json_içerik)
clientsock.close()
except Exception,e:print e
class _main(): #CGI+ALL THREAD
def run(self,salla):
ADDR = (HOST, PORT)
serversock = socket(AF_INET, SOCK_STREAM)
serversock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
serversock.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
serversock.bind(ADDR)
serversock.listen(10)
While True :
try:
#Burada kime yetki verecekseniz ona göre thread açın
thread.start_new_thread(run, (clientsock, addr))
except Exception,e:print "thr start error :",e
if __name__ == "__main__":
ma_in = _main()
thread.start_new_thread(ma_in.run,(None,))
Hiç yorum yok:
Yorum Gönder