Форум сайта python.su
from pylibcurl import Curl, const, lib, CurlError
header = []
c = Curl() # или все опции вставить в конструктор c = Curl('http://www.yandex.ru', followlocation=1, maxredirs=20, encoding='')
c.url = 'http://www.yandex.ru'
c.setopt(followlocation=1, maxredirs=20, encoding='')
c.httpheader = ['X-Client: 1', 'Bot: 1']
c.httpheader = ['X-Client: 2', 'Bot: 2']
c.useragent = 'Opera' # или таким образом устанавливаем опции
c.autoreferer = 1
cookie_file = 'cookie.txt'
c.cookiefile = cookie_file
c.cookiejar = cookie_file
c.writefunction = lambda x: x
c.headerfunction = header.append
c.verbose = 0
c.perform()
print c.effective_url # думаю смысл понятен
from socket import socket
import ssl
s = socket()
c = ssl.wrap_socket(s, cert_reqs=ssl.CERT_REQUIRED, ssl_version=ssl.PROTOCOL_SSLv3, ca_certs='client.pem')
c.connect(('localhost', 8888))
cert = c.getpeercert()
print cert
c.write('dsafsadfasfsafads')
c.close()
s.close()
Traceback (most recent call last):
File "D:\projects\sslclient.py", line 6, in <module>
c.connect(('localhost', 8888))
File "D:\Python26\lib\ssl.py", line 309, in connect
self.do_handshake()
File "D:\Python26\lib\ssl.py", line 293, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:480: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Traceback (most recent call last):
File "D:\projects\sslclient.py", line 6, in <module>
c.connect(('localhost', 8888))
File "D:\Python26\lib\ssl.py", line 309, in connect
self.do_handshake()
File "D:\Python26\lib\ssl.py", line 293, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:480: error:14094410:SSL routines:SSL3_READ_BYTES: sslv3 alert handshake failure
python sample/hello/hello_world.py
i386
GET /hello HTTP/1.0
HTTP/1.0 200 WHYNOT
Date: Thu, 30 Apr 2009 20:40:03 GMT
toto: 4444
Server: fapws2/0.3
Hello World!!Connection closed by foreign host.
amd64
GET /hello HTTP/1.0
HTTP/1.0 200 WHYNOT
Hello World!!Connection closed by foreign host.
The URL is <span tal:replace="request/URL">
http://www.example.com </span>
$ svn merge -rHEAD:xxxx [путь к svn репозиторию] [путь к локальной копии]
#!/usr/bin/env python
def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World!\n']
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()
server {
listen 80;
server_name pytest;
access_log /home/www/python/adserver-access.log combined;
charset utf-8;
location / {
root /home/www/python;
fastcgi_pass unix:/home/www/python/fcgi_wsgi.socket;
fastcgi_intercept_errors off;
fastcgi_index test.py;
fastcgi_param SCRIPT_FILENAME /home/www/python$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /home/www/python;
fastcgi_param PHP_SELF $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_NAME pytest;
fastcgi_param HTTP_HOST pytest;
fastcgi_param SERVER_PORT 80;
fastcgi_param REMOTE_ADDR $remote_addr;
}
}
2009/04/03 12:40:06 [crit] 15019#0: *19 connect() to unix:/tmp/fcgi_wsgi.socket failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: pytest, request: "GET /test.py HTTP/1.1", upstream: "fastcgi://unix:/tmp/fcgi_wsgi.socket:", host: "pytest"
#!/usr/bin/env python
def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World!\n']
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()