Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 18617b7

Browse files
committed
init
0 parents commit 18617b7

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

‎README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Python3-SimpleHTTPServer-with-SSL
2+
3+
## Usage
4+
1. Git clone https://github.com/noobpk/Python3-SimpleHTTPServer-with-SSL.git
5+
2. cd Python3-SimpleHTTPServer-withSSL/
6+
3. Generate your certificate :
7+
1. `chmod +x generate-cert-selfsign.sh`
8+
2. `./generate-cert-selfsign.sh`
9+
4. Add your path of file `cert.pem` to `server.py`
10+
3. Start server: `python3 server.py`
11+
12+
## Configure browsers to allow your certificate
13+
14+
### Google Chrome
15+
Access : `chrome://flags/#allow-insecure-localhost` and click `Enable`
16+
### Firefox
17+
Access: `about:config` then search `security.enterprise_roots.enabled` and click `True`
18+
19+

‎generate-cert-selfsign.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
#generate your certificate self-signed using on local
3+
openssl req -new -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout cert.pem -out cert.pem

‎index.html‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Simple HTTP Server with SSL</title>
5+
</head>
6+
<body>
7+
<h1>Wellcome to my server!!</h1>
8+
</body>
9+
</html>

‎server.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/python3.8
2+
#server.py
3+
from http.server import HTTPServer, SimpleHTTPRequestHandler, HTTPStatus
4+
import socketserver
5+
import ssl
6+
7+
IP = '127.0.0.1'
8+
PORT = 9090
9+
10+
#Start server without ssl
11+
# httpd = socketserver.TCPServer((IP, PORT), SimpleHTTPRequestHandler)
12+
13+
#Start server with ssl
14+
httpd = HTTPServer((IP, PORT), SimpleHTTPRequestHandler)
15+
httpd.socket = ssl.wrap_socket (
16+
httpd.socket, server_side=True,
17+
certfile='/path/to/cert.pem')
18+
19+
print("Server start at: https://{}:{}".format(IP, PORT))
20+
httpd.serve_forever()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /