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