-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Simple Python Web Server | ||
======================== | ||
|
||
This is the source code for howCode's simple Python Web Server. | ||
|
||
You can watch the video that accompanies this source code here: https://youtu.be/hFNZ6kdBgO0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Hello world!</title> | ||
</head> | ||
<body> | ||
<h1>Index page!</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from http.server import HTTPServer, BaseHTTPRequestHandler | ||
|
||
|
||
class Serv(BaseHTTPRequestHandler): | ||
|
||
def do_GET(self): | ||
if self.path == '/': | ||
self.path = '/index.html' | ||
try: | ||
file_to_open = open(self.path[1:]).read() | ||
self.send_response(200) | ||
except: | ||
file_to_open = "File not found" | ||
self.send_response(404) | ||
self.end_headers() | ||
self.wfile.write(bytes(file_to_open, 'utf-8')) | ||
|
||
|
||
httpd = HTTPServer(('localhost', 8080), Serv) | ||
httpd.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Hello world!</title> | ||
</head> | ||
<body> | ||
<h1>Hello World!</h1> | ||
</body> | ||
</html> |