Notice: file_put_contents(): Write of 4955 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50
Warning: file_put_contents(): Only 12288 of 17243 bytes written, possibly out of free disk space in /var/www/tgoop/post.php on line 50 Node.JS [ru] | Серверный JavaScript@we_use_js P.4252
Создайте HTTP-сервер на Node.js, который по запросу возвращает случайную цитату из заранее заданного списка.
Ожидаемое поведение:
• Сервер запускается на порту 3000. • При GET-запросе на /quote сервер возвращает JSON с случайной цитатой. • При запросе на другой путь возвращается сообщение об ошибке.
Решение задачи🔽
const http = require('http');
const quotes = [ "The only limit to our realization of tomorrow is our doubts of today.", "Do not watch the clock. Do what it does. Keep going.", "The future depends on what you do today.", "Success is not the key to happiness. Happiness is the key to success.", "Hardships often prepare ordinary people for an extraordinary destiny." ];
const server = http.createServer((req, res) => { res.setHeader('Content-Type', 'application/json');
Создайте HTTP-сервер на Node.js, который по запросу возвращает случайную цитату из заранее заданного списка.
Ожидаемое поведение:
• Сервер запускается на порту 3000. • При GET-запросе на /quote сервер возвращает JSON с случайной цитатой. • При запросе на другой путь возвращается сообщение об ошибке.
Решение задачи🔽
const http = require('http');
const quotes = [ "The only limit to our realization of tomorrow is our doubts of today.", "Do not watch the clock. Do what it does. Keep going.", "The future depends on what you do today.", "Success is not the key to happiness. Happiness is the key to success.", "Hardships often prepare ordinary people for an extraordinary destiny." ];
const server = http.createServer((req, res) => { res.setHeader('Content-Type', 'application/json');
According to media reports, the privacy watchdog was considering “blacklisting” some online platforms that have repeatedly posted doxxing information, with sources saying most messages were shared on Telegram. The court said the defendant had also incited people to commit public nuisance, with messages calling on them to take part in rallies and demonstrations including at Hong Kong International Airport, to block roads and to paralyse the public transportation system. Various forms of protest promoted on the messaging platform included general strikes, lunchtime protests and silent sit-ins. For crypto enthusiasts, there was the “gm” app, a self-described “meme app” which only allowed users to greet each other with “gm,” or “good morning,” a common acronym thrown around on Crypto Twitter and Discord. But the gm app was shut down back in September after a hacker reportedly gained access to user data. Hui said the messages, which included urging the disruption of airport operations, were attempts to incite followers to make use of poisonous, corrosive or flammable substances to vandalize police vehicles, and also called on others to make weapons to harm police. Choose quality over quantity. Remember that one high-quality post is better than five short publications of questionable value.
from us