Compare commits
1 Commits
main
...
Laboratory
Author | SHA1 | Date | |
---|---|---|---|
|
a0a3fd0be4 |
34
Lab 1/library.xml
Normal file
34
Lab 1/library.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?xml-stylesheet type="text/xsl" href="library.xslt"?>
|
||||||
|
<library>
|
||||||
|
<book>
|
||||||
|
<title>War and Peace</title>
|
||||||
|
<author>Leo Tolstoy</author>
|
||||||
|
<genre>Historical</genre>
|
||||||
|
<year>1869</year>
|
||||||
|
</book>
|
||||||
|
<book>
|
||||||
|
<title>The Captain's Daughter</title>
|
||||||
|
<author>Alexander Pushkin</author>
|
||||||
|
<genre>Novel</genre>
|
||||||
|
<year>1836</year>
|
||||||
|
</book>
|
||||||
|
<book>
|
||||||
|
<title>Crime and Punishment</title>
|
||||||
|
<author>Fyodor Dostoevsky</author>
|
||||||
|
<genre>Philosophical</genre>
|
||||||
|
<year>1866</year>
|
||||||
|
</book>
|
||||||
|
<book>
|
||||||
|
<title>The Three Musketeers</title>
|
||||||
|
<author>Alexandre Dumas</author>
|
||||||
|
<genre>Historical novel</genre>
|
||||||
|
<year>1844</year>
|
||||||
|
</book>
|
||||||
|
<book>
|
||||||
|
<title>Fifteen-year-old captain</title>
|
||||||
|
<author>Jules Verne</author>
|
||||||
|
<genre>Novel</genre>
|
||||||
|
<year>1878</year>
|
||||||
|
</book>
|
||||||
|
</library>
|
47
Lab 1/library.xslt
Normal file
47
Lab 1/library.xslt
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
|
||||||
|
<xsl:template match="/">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Library</title>
|
||||||
|
<style>
|
||||||
|
table {
|
||||||
|
width: 70%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin: 20px auto;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
border: 1px solid black;
|
||||||
|
padding: 10px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color: #9acd32;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2 style="text-align: center;">Library Books</h2>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Author</th>
|
||||||
|
<th>Genre</th>
|
||||||
|
<th>Year</th>
|
||||||
|
</tr>
|
||||||
|
<!-- Цикл по элементам book -->
|
||||||
|
<xsl:for-each select="library/book">
|
||||||
|
<tr>
|
||||||
|
<td><xsl:value-of select="title"/></td>
|
||||||
|
<td><xsl:value-of select="author"/></td>
|
||||||
|
<td><xsl:value-of select="genre"/></td>
|
||||||
|
<td><xsl:value-of select="year"/></td>
|
||||||
|
</tr>
|
||||||
|
</xsl:for-each>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
14
Lab 1/run.py
Normal file
14
Lab 1/run.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import http.server
|
||||||
|
import socketserver
|
||||||
|
|
||||||
|
PORT = 8000
|
||||||
|
DIRECTORY = "."
|
||||||
|
|
||||||
|
class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, directory=DIRECTORY, **kwargs)
|
||||||
|
|
||||||
|
# Запуск сервера на порту 8000
|
||||||
|
with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
||||||
|
print(f"Serving at http://localhost:{PORT}")
|
||||||
|
httpd.serve_forever()
|
Loading…
Reference in New Issue
Block a user