You've already forked tiny-project
Changes
This commit is contained in:
8
python_https_server/README.md
Normal file
8
python_https_server/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Python HTTPS Server (python_https_server)
|
||||
## 简介
|
||||
一个 HTTPS 网络服务器程序
|
||||
## 支持
|
||||
需要一个证书
|
||||
基于 Python 运行
|
||||
## 协议
|
||||
本目录中所有的源代码文件根据 MIT 协议开源
|
49
python_https_server/https_svr_key.pem
Normal file
49
python_https_server/https_svr_key.pem
Normal file
@@ -0,0 +1,49 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCe+wWQgjueNm66
|
||||
zGE85YViKACs3wL786toKY03mreqvQ6Ffz4tTfXtJdFuFem4n+FEUp9SKhpaGPxN
|
||||
mX7cRX/v+6jqkYDOMvyp9w2y/t0rTivSsJr8micFmmRN/gpJH8Ma9Zl28hjPYS8c
|
||||
8gCnIevk/we1vd/IZYCMnRQKuTHh1kUWgBLuRDEwsD2Ka7iVVvonDZMJye42IHoG
|
||||
PO+bif1SBDkW8NkX4TFg0iFKxeplLqAVVx5hgs8pMGjgvGp1HIRJdOcTurXWZIHM
|
||||
cr9nAALRriOA76BOOOYvuljPqf8oPAVqiP+bHHRWNGaeVwAZnGRB369SZbaO9CmZ
|
||||
rf4Xk2pXAgMBAAECggEACYTWLHTfxPVVY/Hg0Jidh+cFQ1SHBTbtyGrUfcPRw3NW
|
||||
bz/TJTtJwk1FYOYG/Hr2LfUUfQLwWPyt/qd2JRI0OtZCoujbYX1EC5kzRMhlzbX8
|
||||
gbz5Sq6gL4GzB8hyLTato+uYqLqOKbyT6ZPD3j31tdxfRc58m68YJ1MwZAP6rJ7j
|
||||
kUGmgg2OlQp7X0EJE5ivDHNYNlluAGD0uLZuyt5+3WnK/ms7sySVBg8BIipS/iQj
|
||||
vv01VlanQNZGYrZurJ8s1PjRyDR/1HI6HjJPCt7XD6LLKla7KV+IBI0tXbkZ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taUMzg/gxaEe2Ss52cvR1TfqWz0WtkyVcaX8TF3q0niecznimiRMc
|
||||
ptUw19v0KM5JbPLdZYPXZehBFdy79wzlBvqScKglNguXF4Hfjqagox+PPzO1HEJk
|
||||
z8GSMfZSm7ayDIJk4bkGZ+KFJZil1wM3hf0QQlZVNZexv6Wv+vyXkpl8Ext5Jb0k
|
||||
1+KOgCJmsCXJZ+D0OeqQ
|
||||
-----END CERTIFICATE-----
|
35
python_https_server/main.py
Normal file
35
python_https_server/main.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# taken from https://gist.github.com/dergachev/7028596
|
||||
#
|
||||
# generate server.xml with the following command:
|
||||
# openssl req -new -x509 -keyout https_svr_key.pem -out https_svr_key.pem -days 3650 -nodes
|
||||
#
|
||||
# run as follows:
|
||||
# python https_svr.py
|
||||
#
|
||||
# then in your browser, visit:
|
||||
# https://localhost:4443
|
||||
#
|
||||
|
||||
import BaseHTTPServer
|
||||
import SimpleHTTPServer
|
||||
import os
|
||||
import socket
|
||||
import ssl
|
||||
|
||||
script_home = os.path.dirname(os.path.abspath(__file__))
|
||||
ip = [(s.connect(('1.1.1.1', 53)), s.getsockname()[0], s.close()) \
|
||||
for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]
|
||||
port = 443
|
||||
|
||||
def main():
|
||||
print ("simple https server, address:%s:%d, document root:%s" % (ip, port, script_home))
|
||||
|
||||
httpd = BaseHTTPServer.HTTPServer(('0.0.0.0', port), SimpleHTTPServer.SimpleHTTPRequestHandler)
|
||||
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='./https_svr_key.pem', server_side=True)
|
||||
httpd.serve_forever()
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.chdir(script_home)
|
||||
main()
|
Reference in New Issue
Block a user