FETCH
This commit is contained in:
parent
add34d944a
commit
3634b6ea4e
13
index.html
13
index.html
@ -10,9 +10,20 @@
|
|||||||
|
|
||||||
<body class="stackedit">
|
<body class="stackedit">
|
||||||
<div class="stackedit__html"><h1 id="значение-ножки">Значение ножки</h1>
|
<div class="stackedit__html"><h1 id="значение-ножки">Значение ножки</h1>
|
||||||
<p>Парам-пам-пам</p>
|
<p id="txtt">Парам-пам-пам</p>
|
||||||
<pre><code></code></pre>
|
<pre><code></code></pre>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
setInterval(() =>
|
||||||
|
fetch('/pin')
|
||||||
|
.then((response) => {
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
document.getElementById("txtt").innerHTML = data;
|
||||||
|
})
|
||||||
|
,2000);
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
5
index.js
5
index.js
@ -44,11 +44,8 @@ const server = http.createServer((req, res) => {
|
|||||||
|
|
||||||
if (req.url == "/") {
|
if (req.url == "/") {
|
||||||
fs.readFile('index.html', 'utf-8', (err, data) => {
|
fs.readFile('index.html', 'utf-8', (err, data) => {
|
||||||
console.log(data);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
res.writeHead(404, {
|
res.writeHead(404);
|
||||||
'Content-Type': 'application/json'
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
|
Loading…
Reference in New Issue
Block a user