Browse Source

new poject 2

master
Tu Quyen Tran Ngoc 4 years ago
commit
b215207109
4 changed files with 79 additions and 0 deletions
  1. 6
    0
      .idea/vcs.xml
  2. 50
    0
      serv.py
  3. 12
    0
      yang.html
  4. 11
    0
      ying.html

+ 6
- 0
.idea/vcs.xml View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

+ 50
- 0
serv.py View File

@@ -0,0 +1,50 @@
import http.server
import urllib.parse

class MyHandler(http.server.BaseHTTPRequestHandler):

def do_GET(self):
self.send_response(200)
self.end_headers()

parsed = urllib.parse.urlparse(self.path)
path = parsed.path
msg = ''

if path == '/ying':
msg = """
<html>
<head>
<title> Ying und Yang </title>
</head>
<body>
ying
<a href="yang">click here</a>
</body>
</html>
"""

if path == '/yang':
msg = """
<html>
<head>
<title> Ying und Yang </title>
</head>
<body>
yang
<a href="ying">click here</a>
</body>
</html>
"""

self.wfile.write(msg.encode('utf-8'))



port = 12345
handler = MyHandler
address = ('', port)

server = http.server.HTTPServer(address, handler)
server.serve_forever()


+ 12
- 0
yang.html View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>yang</title>
</head>
<body>
yang
<a href="ying">Click for ying</a>

</body>
</html>

+ 11
- 0
ying.html View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ying</title>
</head>
<body>
ying
<a href="yang">Click for yang</a>
</body>
</html>

Loading…
Cancel
Save