{"id":373628,"date":"2024-05-21T05:40:37","date_gmt":"2024-05-21T05:40:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=373628"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=373628","title":{"rendered":"<span>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c AI \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442, \u044f \u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0439 \u0422\u0443\u043c\u0430\u043a\u043e\u0432, CTO \u0432 \u041c\u043e\u0440\u0438\u0437\u043e \u0414\u0438\u0434\u0436\u0438\u0442\u0430\u043b.<\/p>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e <a href=\"https:\/\/habr.com\/ru\/articles\/801319\/\" rel=\"noopener noreferrer nofollow\"><u>\u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b<\/u><\/a>, \u043a\u0430\u043a \u043c\u044b \u0432\u00a0\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u00ab\u043f\u043e\u0442\u0440\u043e\u0433\u0430\u043b\u0438\u00bb \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0434\u043b\u044f\u00a0\u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041d\u043e\u00a0\u0442\u0430\u043c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0445 \u0432\u044b\u0432\u043e\u0434\u043e\u0432 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u00a0\u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u00a0\u044d\u0442\u043e\u043c \u043d\u0435\u00a0\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u2014 \u0438\u0445 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u0440\u0435\u0445 AI-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432: Phind, ChatGPT, Machinet.<\/p>\n<h3>\u0418\u0434\u0435\u044f \u0438 \u043f\u0440\u043e\u043c\u043f\u0442<\/h3>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c JS \u0438 html \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0433\u043e\u0434\u044b \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u0433\u043e\u0440\u043e\u0434\u0430. \u041d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0444\u043e\u0440\u043c\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u0440\u043e\u0434\u0430, \u043a\u043d\u043e\u043f\u043a\u0430 &#171;\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&#187;. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c \u0443\u0447\u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 CORS.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430.\u00a0\u00a0<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u0433\u043e\u0440\u043e\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0434\u043e\u043b\u0433\u043e\u0442\u0443 \u0438 \u0448\u0438\u0440\u043e\u0442\u0443 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 API<\/p>\n<p><code>curl -X POST <br \/> -H \"Content-Type: application\/json\" <br \/> -H \"Accept: application\/json\" <br \/> -H \"Authorization: Token {API_TOKEN}\" <br \/> -H \"X-Secret: {SECRET_TOKEN}\" <br \/> -d '[ \"{\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430}\" ]' <br \/> https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address<\/code><\/p>\n<\/li>\n<\/ol>\n<ol start=\"3\">\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u043b\u0433\u043e\u0442\u0443 \u0438 \u0448\u0438\u0440\u043e\u0442\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441 &#8212;\u00a0 https:\/\/api.openweathermap.org\/data\/2.5\/weather?lat={lat}&amp;lon={lon}&amp;appid={API key}<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a API.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u043f\u0440\u043e\u043c\u043f\u0442 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u0442\u0440\u0435\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<h3>ChatGPT<\/h3>\n<p>*\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 HTML \u0438 JavaScript, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c:*<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">&lt;!DOCTYPE html><br \/>&lt;<strong>html<\/strong> lang=&#187;en&#187;><br \/>&lt;<strong>head<\/strong>><br \/>&lt;<strong>meta<\/strong> charset=&#187;UTF-8&#8243;><br \/>&lt;<strong>meta<\/strong> name=&#187;viewport&#187; content=&#187;width=device-width, initial-scale=1.0&#8243;><br \/>&lt;<strong>title<\/strong>>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&lt;\/<strong>title<\/strong>><br \/>&lt;\/<strong>head<\/strong>><br \/>&lt;<strong>body<\/strong>><br \/>&lt;<strong>h2<\/strong>>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&lt;\/<strong>h2<\/strong>><br \/>&lt;<strong>form<\/strong> id=&#187;weatherForm&#187;><br \/>\u00a0 &lt;<strong>label<\/strong> for=&#187;cityInput&#187;>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430:&lt;\/<strong>label<\/strong>>&lt;<strong>br<\/strong>><br \/>\u00a0 &lt;<strong>input<\/strong> type=&#187;text&#187; id=&#187;cityInput&#187; name=&#187;cityInput&#187;>&lt;<strong>br<\/strong>><br \/>\u00a0 &lt;<strong>button<\/strong> type=&#187;submit&#187;>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&lt;\/<strong>button<\/strong>><br \/>&lt;\/<strong>form<\/strong>><br \/>&lt;<strong>div<\/strong> id=&#187;weatherResult&#187;>&lt;\/<strong>div<\/strong>><\/p>\n<p>&lt;<strong>script<\/strong>><br \/>document.getElementById(&#8216;weatherForm&#8217;).addEventListener(&#8216;submit&#8217;, <strong>function<\/strong>(event) {<br \/>\u00a0 event.preventDefault(); \/\/ Prevent default form submission<br \/>\u00a0 <br \/>\u00a0 <strong>var<\/strong> city = document.getElementById(&#8216;cityInput&#8217;).value.trim();<br \/>\u00a0 <strong>if<\/strong> (city === &#187;) {<br \/>\u00a0 \u00a0 alert(&#8216;\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430.&#8217;);<br \/>\u00a0 \u00a0 <strong>return<\/strong>;<br \/>\u00a0 }<br \/>\u00a0 <br \/>\u00a0 fetchCoordinates(city)<br \/>\u00a0 \u00a0 .then(<strong>function<\/strong>(coordinates) {<br \/>\u00a0 \u00a0 \u00a0 <strong>return<\/strong> fetchWeather(coordinates.lat, coordinates.lon);<br \/>\u00a0 \u00a0 })<br \/>\u00a0 \u00a0 .then(<strong>function<\/strong>(weather) {<br \/>\u00a0 \u00a0 \u00a0 displayWeather(weather);<br \/>\u00a0 \u00a0 })<br \/>\u00a0 \u00a0 .catch(<strong>function<\/strong>(error) {<br \/>\u00a0 \u00a0 \u00a0 console.error(&#8216;\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430:&#8217;, error);<br \/>\u00a0 \u00a0 });<br \/>});<\/p>\n<p><strong>function<\/strong> <strong>fetchCoordinates<\/strong>(city) {<br \/>\u00a0 <strong>var<\/strong> apiToken = &#8216;{API_TOKEN}&#8217;;<br \/>\u00a0 <strong>var<\/strong> secretToken = &#8216;{SECRET_TOKEN}&#8217;;<br \/>\u00a0 <br \/>\u00a0 <strong>return<\/strong> fetch(&#8216;https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address&#8217;, {<br \/>\u00a0 \u00a0 method: &#8216;POST&#8217;,<br \/>\u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 &#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 &#8216;Accept&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 &#8216;Authorization&#8217;: &#8216;Token &#8216; + apiToken,<br \/>\u00a0 \u00a0 \u00a0 &#8216;X-Secret&#8217;: secretToken<br \/>\u00a0 \u00a0 },<br \/>\u00a0 \u00a0 body: JSON.stringify([city])<br \/>\u00a0 })<br \/>\u00a0 .then(<strong>function<\/strong>(response) {<br \/>\u00a0 \u00a0 <strong>if<\/strong> (!response.ok) {<br \/>\u00a0 \u00a0 \u00a0 <strong>throw<\/strong> <strong>new<\/strong> Error(&#8216;\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0433\u043e\u0440\u043e\u0434\u0430.&#8217;);<br \/>\u00a0 \u00a0 }<br \/>\u00a0 \u00a0 <strong>return<\/strong> response.json();<br \/>\u00a0 })<br \/>\u00a0 .then(<strong>function<\/strong>(data) {<br \/>\u00a0 \u00a0 <strong>var<\/strong> coordinates = data[0].geo_lat &amp;&amp; data[0].geo_lon ? { lat: data[0].geo_lat, lon: data[0].geo_lon } : <strong>null<\/strong>;<br \/>\u00a0 \u00a0 <strong>if<\/strong> (!coordinates) {<br \/>\u00a0 \u00a0 \u00a0 <strong>throw<\/strong> <strong>new<\/strong> Error(&#8216;\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u043e\u0440\u043e\u0434\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b.&#8217;);<br \/>\u00a0 \u00a0 }<br \/>\u00a0 \u00a0 <strong>return<\/strong> coordinates;<br \/>\u00a0 });<br \/>}<\/p>\n<p><strong>function<\/strong> <strong>fetchWeather<\/strong>(lat, lon) {<br \/>\u00a0 <strong>var<\/strong> apiKey = &#8216;{API_KEY}&#8217;;<br \/>\u00a0 <br \/>\u00a0 <strong>return<\/strong> fetch(`https:\/\/api.openweathermap.org\/data\/2.5\/weather?lat=${lat}&amp;lon=${lon}&amp;appid=${apiKey}`)<br \/>\u00a0 \u00a0 .then(<strong>function<\/strong>(response) {<br \/>\u00a0 \u00a0 \u00a0 <strong>if<\/strong> (!response.ok) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 <strong>throw<\/strong> <strong>new<\/strong> Error(&#8216;\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u0433\u043e\u0434\u0435.&#8217;);<br \/>\u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 \u00a0 <strong>return<\/strong> response.json();<br \/>\u00a0 \u00a0 });<br \/>}<\/p>\n<p><strong>function<\/strong> <strong>displayWeather<\/strong>(weather) {<br \/>\u00a0 <strong>var<\/strong> weatherResultDiv = document.getElementById(&#8216;weatherResult&#8217;);<br \/>\u00a0 weatherResultDiv.innerHTML = &#187;;<br \/>\u00a0 <br \/>\u00a0 <strong>var<\/strong> cityName = weather.name;<br \/>\u00a0 <strong>var<\/strong> weatherDescription = weather.weather &amp;&amp; weather.weather[0] ? weather.weather[0].description : &#187;;<br \/>\u00a0 <strong>var<\/strong> temperature = weather.main &amp;&amp; weather.main.temp ? Math.round(weather.main.temp &#8212; 273.15) : &#187;;<br \/>\u00a0 <br \/>\u00a0 <strong>var<\/strong> weatherInfo = document.createElement(&#8216;p&#8217;);<br \/>\u00a0 weatherInfo.textContent = `\u041f\u043e\u0433\u043e\u0434\u0430 \u0432 \u0433\u043e\u0440\u043e\u0434\u0435 ${cityName}: ${weatherDescription}, \u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430: ${temperature}\u00b0C`;<br \/>\u00a0 weatherResultDiv.appendChild(weatherInfo);<br \/>}<br \/>&lt;\/<strong>script<\/strong>><br \/>&lt;\/<strong>body<\/strong>><br \/>&lt;\/<strong>html<\/strong>><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>*\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c `{API_TOKEN}`, `{SECRET_TOKEN}` \u0438 `{API_KEY}` \u043d\u0430 \u0441\u0432\u043e\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 CORS \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.*\u00a0<\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u043d\u0430\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 CORS.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/869\/08c\/ee6\/86908cee6c8afe59925aed251db00339.png\" width=\"844\" height=\"149\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/869\/08c\/ee6\/86908cee6c8afe59925aed251db00339.png\"\/><\/figure>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/661\/33d\/3a1\/66133d3a1123e0fd9c0ed0f2ebb2997c.png\" width=\"729\" height=\"172\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/661\/33d\/3a1\/66133d3a1123e0fd9c0ed0f2ebb2997c.png\"\/><\/figure>\n<p>\u0412\u043e\u0442, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b ChatGPT<\/p>\n<p>*\u0427\u0442\u043e\u0431\u044b \u043e\u0431\u043e\u0439\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 CORS \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a API \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u043f\u0440\u043e\u043a\u0441\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Node.js, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a API `cleaner.dadata.ru` \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442.*<\/p>\n<p>*\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 Node.js:*<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>const<\/strong> express = require(&#8216;express&#8217;);<br \/><strong>const<\/strong> fetch = require(&#8216;node-fetch&#8217;);<br \/><strong>const<\/strong> cors = require(&#8216;cors&#8217;);<\/p>\n<p><strong>const<\/strong> app = express();<br \/><strong>const<\/strong> PORT = process.env.PORT || 3000;<\/p>\n<p>app.use(cors());<\/p>\n<p>app.post(&#8216;\/getCoordinates&#8217;, <strong>async<\/strong> (req, res) => {<br \/>\u00a0 <strong>try<\/strong> {<br \/>\u00a0 \u00a0 <strong>const<\/strong> cityName = req.body.cityName;<br \/>\u00a0 \u00a0 <strong>const<\/strong> response = <strong>await<\/strong> fetch(&#8216;https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address&#8217;, {<br \/>\u00a0 \u00a0 \u00a0 method: &#8216;POST&#8217;,<br \/>\u00a0 \u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Accept&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Authorization&#8217;: &#8216;Token {API_TOKEN}&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;X-Secret&#8217;: &#8216;{SECRET_TOKEN}&#8217;<br \/>\u00a0 \u00a0 \u00a0 },<br \/>\u00a0 \u00a0 \u00a0 body: JSON.stringify([cityName])<br \/>\u00a0 \u00a0 });<\/p>\n<p>\u00a0 \u00a0 <strong>const<\/strong> data = <strong>await<\/strong> response.json();<br \/>\u00a0 \u00a0 <strong>const<\/strong> coordinates = data[0].geo_lat &amp;&amp; data[0].geo_lon ? { lat: data[0].geo_lat, lon: data[0].geo_lon } : <strong>null<\/strong>;<\/p>\n<p>\u00a0 \u00a0 <strong>if<\/strong> (coordinates) {<br \/>\u00a0 \u00a0 \u00a0 res.json(coordinates);<br \/>\u00a0 \u00a0 } <strong>else<\/strong> {<br \/>\u00a0 \u00a0 \u00a0 res.status(404).json({ error: &#8216;Coordinates not found for the provided city name&#8217; });<br \/>\u00a0 \u00a0 }<br \/>\u00a0 } <strong>catch<\/strong> (error) {<br \/>\u00a0 \u00a0 console.error(&#8216;Error:&#8217;, error);<br \/>\u00a0 \u00a0 res.status(500).json({ error: &#8216;Internal Server Error&#8217; });<br \/>\u00a0 }<br \/>});<\/p>\n<p>app.listen(PORT, () => {<br \/>\u00a0 console.log(`Server is running on port ${PORT}`);<br \/>});<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>*\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434\u0435:*<\/p>\n<p>1. *\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 `express` \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430.*<\/p>\n<p>2. *\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 `node-fetch` \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.*<\/p>\n<p>3. *\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 `cors` \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 CORS \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438.*<\/p>\n<p>4. *\u0421\u043e\u0437\u0434\u0430\u043d \u043c\u0430\u0440\u0448\u0440\u0443\u0442 `\/getCoordinates`, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 POST \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0433\u043e\u0440\u043e\u0434\u0430, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API `cleaner.dadata.ru` \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0433\u043e\u0440\u043e\u0434\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0443.*<\/p>\n<p>*\u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0433\u043e\u0440\u043e\u0434\u0430, \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0433\u043e\u0434\u044b \u043a API `api.openweathermap.org`.*<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">&lt;<strong>html<\/strong> lang=&#187;en&#187;><br \/>&lt;<strong>head<\/strong>><br \/>\u00a0 &lt;<strong>meta<\/strong> charset=&#187;UTF-8&#8243;><br \/>\u00a0 &lt;<strong>meta<\/strong> name=&#187;viewport&#187; content=&#187;width=device-width, initial-scale=1.0&#8243;><br \/>\u00a0 &lt;<strong>title<\/strong>>Weather App&lt;\/<strong>title<\/strong>><br \/>&lt;\/<strong>head<\/strong>><br \/>&lt;<strong>body<\/strong>><br \/>\u00a0 &lt;<strong>h1<\/strong>>Weather App&lt;\/<strong>h1<\/strong>><br \/>\u00a0 &lt;<strong>form<\/strong> id=&#187;cityForm&#187;><br \/>\u00a0 \u00a0 &lt;<strong>label<\/strong> for=&#187;cityName&#187;>Enter city name:&lt;\/<strong>label<\/strong>><br \/>\u00a0 \u00a0 &lt;<strong>input<\/strong> type=&#187;text&#187; id=&#187;cityName&#187; name=&#187;cityName&#187;><br \/>\u00a0 \u00a0 &lt;<strong>button<\/strong> type=&#187;submit&#187;>Get Weather&lt;\/<strong>button<\/strong>><br \/>\u00a0 &lt;\/<strong>form<\/strong>><br \/>\u00a0 &lt;<strong>div<\/strong> id=&#187;weatherData&#187;>&lt;\/<strong>div<\/strong>><\/p>\n<p>\u00a0 &lt;<strong>script<\/strong>><br \/>\u00a0 \u00a0 document.getElementById(&#8216;cityForm&#8217;).addEventListener(&#8216;submit&#8217;, <strong>async<\/strong> (event) => {<br \/>\u00a0 \u00a0 \u00a0 event.preventDefault();<br \/>\u00a0 \u00a0 \u00a0 <br \/>\u00a0 \u00a0 \u00a0 <strong>const<\/strong> cityName = document.getElementById(&#8216;cityName&#8217;).value;<br \/>\u00a0 \u00a0 \u00a0 <strong>const<\/strong> response = <strong>await<\/strong> fetch(&#8216;http:\/\/localhost:3000\/getCoordinates&#8217;, {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 method: &#8216;POST&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#8216;Content-Type&#8217;: &#8216;application\/json&#8217;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 },<br \/>\u00a0 \u00a0 \u00a0 \u00a0 body: JSON.stringify({ cityName })<br \/>\u00a0 \u00a0 \u00a0 });<\/p>\n<p>\u00a0 \u00a0 \u00a0 <strong>const<\/strong> data = <strong>await<\/strong> response.json();<\/p>\n<p>\u00a0 \u00a0 \u00a0 <strong>if<\/strong> (data.error) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 document.getElementById(&#8216;weatherData&#8217;).textContent = data.error;<br \/>\u00a0 \u00a0 \u00a0 } <strong>else<\/strong> {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 <strong>const<\/strong> weatherResponse = <strong>await<\/strong> fetch(`https:\/\/api.openweathermap.org\/data\/2.5\/weather?lat=${data.lat}&amp;lon=${data.lon}&amp;appid={API key}`);<br \/>\u00a0 \u00a0 \u00a0 \u00a0 <strong>const<\/strong> weatherData = <strong>await<\/strong> weatherResponse.json();<br \/>\u00a0 \u00a0 \u00a0 \u00a0 document.getElementById(&#8216;weatherData&#8217;).textContent = JSON.stringify(weatherData, <strong>null<\/strong>, 2);<br \/>\u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 });<br \/>\u00a0 &lt;\/<strong>script<\/strong>><br \/>&lt;\/<strong>body<\/strong>><br \/>&lt;\/<strong>html<\/strong>><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>*\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 JavaScript \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0433\u043e\u0440\u043e\u0434\u0430, \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0433\u043e\u0434\u044b \u043a API `api.openweathermap.org`.*<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>Error [ERR_REQUIRE_ESM]: require() of ES Module &#8230;\/ai\/chat-gpt\/node_modules\/node-fetch\/src\/index.js from &#8230;\/ai\/chat-gpt\/server.js not supported. Instead change the require of index.js in &#8230;\/ai\/chat-gpt\/server.js to a dynamic import() which is available in all CommonJS modules. at Object.&lt;anonymous> (&#8230;\/ai\/chat-gpt\/server.js:50:15) { code: &#8216;ERR_REQUIRE_ESM&#8217; }<\/p>\n<p>\u041f\u0440\u043e\u0448\u0443 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430, \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 axios.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>const<\/strong> express = require(&#8216;express&#8217;);<br \/><strong>const<\/strong> axios = require(&#8216;axios&#8217;);<br \/><strong>const<\/strong> cors = require(&#8216;cors&#8217;);<\/p>\n<p><strong>const<\/strong> app = express();<br \/><strong>const<\/strong> PORT = process.env.PORT || 3000;<\/p>\n<p>app.use(cors());<br \/>app.use(express.json());<\/p>\n<p>app.post(&#8216;\/getCoordinates&#8217;, <strong>async<\/strong> (req, res) => {<br \/>\u00a0 <strong>try<\/strong> {<br \/>\u00a0 \u00a0 <strong>const<\/strong> cityName = req.body.cityName;<br \/>\u00a0 \u00a0 <strong>const<\/strong> response = <strong>await<\/strong> axios.post(&#8216;https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address&#8217;, [cityName], {<br \/>\u00a0 \u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Accept&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Authorization&#8217;: &#8216;Token {API_TOKEN}&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;X-Secret&#8217;: &#8216;{SECRET_TOKEN}&#8217;<br \/>\u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 });<\/p>\n<p>\u00a0 \u00a0 <strong>const<\/strong> data = response.data;<br \/>\u00a0 \u00a0 <strong>const<\/strong> coordinates = data[0].geo_lat &amp;&amp; data[0].geo_lon ? { lat: data[0].geo_lat, lon: data[0].geo_lon } : <strong>null<\/strong>;<\/p>\n<p>\u00a0 \u00a0 <strong>if<\/strong> (coordinates) {<br \/>\u00a0 \u00a0 \u00a0 res.json(coordinates);<br \/>\u00a0 \u00a0 } <strong>else<\/strong> {<br \/>\u00a0 \u00a0 \u00a0 res.status(404).json({ error: &#8216;Coordinates not found for the provided city name&#8217; });<br \/>\u00a0 \u00a0 }<br \/>\u00a0 } <strong>catch<\/strong> (error) {<br \/>\u00a0 \u00a0 console.error(&#8216;Error:&#8217;, error);<br \/>\u00a0 \u00a0 res.status(500).json({ error: &#8216;Internal Server Error&#8217; });<br \/>\u00a0 }<br \/>});<\/p>\n<p>app.listen(PORT, () => {<br \/>\u00a0 console.log(`Server is running on port ${PORT}`);<br \/>});<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u0443\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/05e\/5ed\/e75\/05e5ede75f9f55af792f7497fdccd979.png\" width=\"1308\" height=\"206\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/05e\/5ed\/e75\/05e5ede75f9f55af792f7497fdccd979.png\"\/><\/figure>\n<p>\u041f\u043e\u043f\u0440\u043e\u0448\u0443 \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 API.<\/p>\n<p>*\u0412\u044b\u0432\u0435\u0434\u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 API, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0430\u043a\u0430\u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0433\u043e\u0434\u0430, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u0435\u0442\u0440\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435*<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/685\/f30\/356\/685f30356276e679bd567d2e421b1c72.png\" width=\"633\" height=\"1271\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/685\/f30\/356\/685f30356276e679bd567d2e421b1c72.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/df9\/85a\/6a6\/df985a6a6190c534514695b4dab70c40.png\" width=\"502\" height=\"370\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/df9\/85a\/6a6\/df985a6a6190c534514695b4dab70c40.png\"\/><\/figure>\n<h3><\/h3>\n<h3>Phind<\/h3>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u043f\u0440\u043e\u043c\u043f\u0442 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0436\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435. Phind \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u043b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c html \u0438 js \u043a\u043e\u0434 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0447\u0442\u043e \u0440\u0430\u0434\u0443\u0435\u0442.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c59\/635\/269\/c5963526936082f4baf8c6ae755565c0.png\" width=\"1096\" height=\"663\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c59\/635\/269\/c5963526936082f4baf8c6ae755565c0.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e73\/81a\/845\/e7381a8456f20080a88953e898db2626.png\" width=\"874\" height=\"1302\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e73\/81a\/845\/e7381a8456f20080a88953e898db2626.png\"\/><\/figure>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0448\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 CORS. \u0412\u0438\u0436\u0443, \u0447\u0442\u043e Phind \u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a11\/552\/b60\/a11552b601ea69e347d7dfe08d43307f.png\" width=\"878\" height=\"1064\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a11\/552\/b60\/a11552b601ea69e347d7dfe08d43307f.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e5e\/417\/d8c\/e5e417d8c85f85977677a61e71adf01e.png\" width=\"877\" height=\"698\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e5e\/417\/d8c\/e5e417d8c85f85977677a61e71adf01e.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0431\u0443\u044e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0421\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e, \u043a\u0430\u043a \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/333\/822\/7ce\/3338227ce1ce9b21b07e2f11233ce51f.png\" width=\"879\" height=\"1275\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/333\/822\/7ce\/3338227ce1ce9b21b07e2f11233ce51f.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/815\/f6a\/05c\/815f6a05cad7caa86eea5ea03ecbdcfd.png\" width=\"883\" height=\"730\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/815\/f6a\/05c\/815f6a05cad7caa86eea5ea03ecbdcfd.png\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0431\u0443\u044e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>&#171;`<\/p>\n<p>Error [ERR_REQUIRE_ESM]: require() of ES Module &#8230;\/ai\/chat-gpt\/node_modules\/node-fetch\/src\/index.js from &#8230;\/ai\/chat-gpt\/server.js not supported. Instead change the require of index.js in &#8230;\/ai\/chat-gpt\/server.js to a dynamic import() which is available in all CommonJS modules. at Object.&lt;anonymous> (&#8230;\/ai\/chat-gpt\/server.js:50:15) { code: &#8216;ERR_REQUIRE_ESM&#8217; }<\/p>\n<p>&#171;`<\/p>\n<p>\u041f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0442\u0432\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 ChatGPT, \u043e\u043d \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0438 \u0432 \u043d\u0435\u043c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dde\/34b\/349\/dde34b349a8c351c8661d4c86f958041.png\" width=\"883\" height=\"1253\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dde\/34b\/349\/dde34b349a8c351c8661d4c86f958041.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0431\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d7d\/55e\/921\/d7d55e921526b438c06d7ee7808c8291.png\" width=\"644\" height=\"142\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d7d\/55e\/921\/d7d55e921526b438c06d7ee7808c8291.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0448\u0443 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0430\u043f\u0438, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a\u0430\u044f \u043f\u043e\u0433\u043e\u0434\u0430, \u0432\u0435\u0442\u0435\u0440 \u0438 \u0442.\u0434.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eb8\/409\/a02\/eb8409a02cd3d43d32731069bfbaa120.png\" width=\"896\" height=\"895\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eb8\/409\/a02\/eb8409a02cd3d43d32731069bfbaa120.png\"\/><\/figure>\n<p>\u041f\u0440\u0430\u0432\u043b\u044e \u043a\u043e\u0434 \u0438 \u043f\u0440\u043e\u0431\u0443\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a84\/1b9\/5d3\/a841b95d3c53d854ef659daba4f81ad4.png\" width=\"607\" height=\"274\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a84\/1b9\/5d3\/a841b95d3c53d854ef659daba4f81ad4.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u044e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e.<\/p>\n<p>\u041d\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u2014 \u043f\u0440\u043e\u0448\u0443 \u0435\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/184\/02a\/ec4\/18402aec45ea720846f2465f8ad11d8a.png\" width=\"898\" height=\"1076\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/184\/02a\/ec4\/18402aec45ea720846f2465f8ad11d8a.png\"\/><\/figure>\n<p>\u0421\u043d\u043e\u0432\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u0441 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0436\u0435 \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e.<\/p>\n<h3>Machinet<\/h3>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u043f\u0440\u043e\u043c\u043f\u0442, \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0442\u0432\u0435\u0442:<\/p>\n<p>*\u0425\u043e\u0440\u043e\u0448\u043e, \u044f \u043c\u043e\u0433\u0443 \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0433\u043e\u0434\u044b \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u0433\u043e\u0440\u043e\u0434\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c JavaScript \u0438 HTML. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c HTML-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430:*<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">&lt;!DOCTYPE html><br \/>&lt;<strong>html<\/strong>><br \/>&lt;<strong>head<\/strong>><br \/>\u00a0 &lt;<strong>title<\/strong>>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0433\u043e\u0434\u044b&lt;\/<strong>title<\/strong>><br \/>\u00a0 &lt;<strong>script<\/strong> src=&#187;https:\/\/code.jquery.com\/jquery-3.6.0.min.js&#187;>&lt;\/<strong>script<\/strong>><br \/>&lt;\/<strong>head<\/strong>><br \/>&lt;<strong>body<\/strong>><br \/>\u00a0 &lt;<strong>h1<\/strong>>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0433\u043e\u0434\u044b \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u0433\u043e\u0440\u043e\u0434\u0430&lt;\/<strong>h1<\/strong>><br \/>\u00a0 &lt;<strong>form<\/strong> id=&#187;weatherForm&#187;><br \/>\u00a0 \u00a0 &lt;<strong>label<\/strong> for=&#187;cityInput&#187;>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430:&lt;\/<strong>label<\/strong>><br \/>\u00a0 \u00a0 &lt;<strong>input<\/strong> type=&#187;text&#187; id=&#187;cityInput&#187; required><br \/>\u00a0 \u00a0 &lt;<strong>button<\/strong> type=&#187;submit&#187;>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&lt;\/<strong>button<\/strong>><br \/>\u00a0 &lt;\/<strong>form<\/strong>><br \/>\u00a0 &lt;<strong>div<\/strong> id=&#187;weatherResult&#187;>&lt;\/<strong>div<\/strong>><\/p>\n<p>\u00a0 &lt;<strong>script<\/strong>><br \/>\u00a0 \u00a0 \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u043e\u0440\u043c\u044b<br \/>\u00a0 \u00a0 $(&#171;#weatherForm&#187;).submit(<strong>function<\/strong>(event) {<br \/>\u00a0 \u00a0 \u00a0 event.preventDefault(); \/\/ \u041f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0444\u043e\u0440\u043c\u044b<\/p>\n<p>\u00a0 \u00a0 \u00a0 <strong>var<\/strong> city = $(&#171;#cityInput&#187;).val(); \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0430<\/p>\n<p>\u00a0 \u00a0 \u00a0 \/\/ \u0417\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0433\u043e\u0442\u044b \u0438 \u0448\u0438\u0440\u043e\u0442\u044b<br \/>\u00a0 \u00a0 \u00a0 $.ajax({<br \/>\u00a0 \u00a0 \u00a0 \u00a0 url: &#171;https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address&#187;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 type: &#171;POST&#187;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#171;Content-Type&#187;: &#171;application\/json&#187;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#171;Accept&#187;: &#171;application\/json&#187;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#171;Authorization&#187;: &#171;Token {API_TOKEN}&#187;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#171;X-Secret&#187;: &#171;{SECRET_TOKEN}&#187;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 },<br \/>\u00a0 \u00a0 \u00a0 \u00a0 data: JSON.stringify([city]),<br \/>\u00a0 \u00a0 \u00a0 \u00a0 success: <strong>function<\/strong>(response) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <strong>var<\/strong> latitude = response[0].geo_lat;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <strong>var<\/strong> longitude = response[0].geo_lon;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u0417\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0433\u043e\u0434\u044b<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 $.ajax({<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 url: &#171;https:\/\/api.openweathermap.org\/data\/2.5\/weather&#187;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 type: &#171;GET&#187;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 data: {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lat: latitude,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lon: longitude,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 appid: &#171;{API key}&#187;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 success: <strong>function<\/strong>(weatherData) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a API<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 $(&#171;#weatherResult&#187;).html(&#171;\u0422\u0435\u043a\u0443\u0449\u0430\u044f \u043f\u043e\u0433\u043e\u0434\u0430 \u0432 \u0433\u043e\u0440\u043e\u0434\u0435 &#187; + city + &#171;: &#187; + weatherData.weather[0].description);<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 },<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 error: <strong>function<\/strong>() {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 $(&#171;#weatherResult&#187;).html(&#171;\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u0433\u043e\u0434\u044b&#187;);<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 });<br \/>\u00a0 \u00a0 \u00a0 \u00a0 },<br \/>\u00a0 \u00a0 \u00a0 \u00a0 error: <strong>function<\/strong>() {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 $(&#171;#weatherResult&#187;).html(&#171;\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0433\u043e\u0440\u043e\u0434\u0430&#187;);<br \/>\u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 \u00a0 });<br \/>\u00a0 \u00a0 });<br \/>\u00a0 &lt;\/<strong>script<\/strong>><br \/>&lt;\/<strong>body<\/strong>><br \/>&lt;\/<strong>html<\/strong>><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>*\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c jQuery \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 AJAX-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u041f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0444\u043e\u0440\u043c\u044b, \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0433\u043e\u0442\u044b \u0438 \u0448\u0438\u0440\u043e\u0442\u044b \u0433\u043e\u0440\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e API \u043e\u0442 Dadata, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0433\u043e\u0434\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e API \u043e\u0442 OpenWeatherMap. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 \u0441 id &#171;weatherResult&#187;.*<\/p>\n<p>*\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c {API_TOKEN}, {SECRET_TOKEN} \u0438 {API key} \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445.*<\/p>\n<p>\u041f\u0440\u043e\u0431\u0443\u044e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441. \u0421\u043d\u043e\u0432\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0448\u0438\u0431\u043a\u0443 CORS, \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u0442 \u0436\u0435 \u0442\u0435\u043a\u0441\u0442, \u0447\u0442\u043e \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044f\u0445 \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ff\/f4f\/f1f\/0fff4ff1fde97fafd9aea78fbbff3023.png\" width=\"827\" height=\"787\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0ff\/f4f\/f1f\/0fff4ff1fde97fafd9aea78fbbff3023.png\"\/><\/figure>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u044e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9e6\/163\/3d2\/9e61633d2a39ddd06f4486b671dcacfd.png\" width=\"828\" height=\"1173\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9e6\/163\/3d2\/9e61633d2a39ddd06f4486b671dcacfd.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0431\u0443\u044e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">app.<strong>use<\/strong>(corsAnywhere({<br \/>\u00a0 \u00a0 \u00a0 \u00a0 ^<br \/>TypeError: corsAnywhere <strong>is<\/strong> <strong>not<\/strong> a <strong>function<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/455\/872\/73e\/45587273ef4f458e66b91932ed71f6fb.png\" width=\"823\" height=\"609\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/455\/872\/73e\/45587273ef4f458e66b91932ed71f6fb.png\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f. \u041d\u043e \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u043e\u0432\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443, \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u043e\u0448\u0443 \u0435\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/349\/4af\/aad\/3494afaad6095294f8fc451924c46c08.png\" width=\"802\" height=\"1094\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/349\/4af\/aad\/3494afaad6095294f8fc451924c46c08.png\"\/><\/figure>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0431\u0443\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0435\u0449\u0435 \u0440\u0430\u0437, \u043d\u043e \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d35\/f5c\/658\/d35f5c658e9364d327d25036778f873f.png\" width=\"813\" height=\"473\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d35\/f5c\/658\/d35f5c658e9364d327d25036778f873f.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0431\u0443\u044e \u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/851\/c50\/598\/851c505981ff015dfb423a3bf12a5639.png\" width=\"799\" height=\"718\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/851\/c50\/598\/851c505981ff015dfb423a3bf12a5639.png\"\/><\/figure>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c.<\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/h3>\n<p>\u0425\u0443\u0436\u0435 \u0432\u0441\u0435\u0445 \u0441 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c Machinet, \u0435\u0439 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0434\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u043e\u043d\u0430 \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 ChatGPT \u0438 Phind, \u0442\u043e \u044f \u0431\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u043b Phind, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0430 \u0434\u0430\u0432\u0430\u043b\u0430 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u043b\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/807703\/\"> https:\/\/habr.com\/ru\/articles\/807703\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442, \u044f \u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0439 \u0422\u0443\u043c\u0430\u043a\u043e\u0432, CTO \u0432 \u041c\u043e\u0440\u0438\u0437\u043e \u0414\u0438\u0434\u0436\u0438\u0442\u0430\u043b.<\/p>\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e <a href=\"https:\/\/habr.com\/ru\/articles\/801319\/\" rel=\"noopener noreferrer nofollow\"><u>\u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b<\/u><\/a>, \u043a\u0430\u043a \u043c\u044b \u0432\u00a0\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u00ab\u043f\u043e\u0442\u0440\u043e\u0433\u0430\u043b\u0438\u00bb \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0434\u043b\u044f\u00a0\u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041d\u043e\u00a0\u0442\u0430\u043c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0445 \u0432\u044b\u0432\u043e\u0434\u043e\u0432 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u00a0\u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u00a0\u044d\u0442\u043e\u043c \u043d\u0435\u00a0\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u2014 \u0438\u0445 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u0440\u0435\u0445 AI-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432: Phind, ChatGPT, Machinet.<\/p>\n<h3>\u0418\u0434\u0435\u044f \u0438 \u043f\u0440\u043e\u043c\u043f\u0442<\/h3>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c JS \u0438 html \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0433\u043e\u0434\u044b \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u0433\u043e\u0440\u043e\u0434\u0430. \u041d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0444\u043e\u0440\u043c\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u0440\u043e\u0434\u0430, \u043a\u043d\u043e\u043f\u043a\u0430 &#171;\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&#187;. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c \u0443\u0447\u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 CORS.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430.\u00a0\u00a0<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u0433\u043e\u0440\u043e\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0434\u043e\u043b\u0433\u043e\u0442\u0443 \u0438 \u0448\u0438\u0440\u043e\u0442\u0443 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 API<\/p>\n<p><code>curl -X POST <br \/> -H \"Content-Type: application\/json\" <br \/> -H \"Accept: application\/json\" <br \/> -H \"Authorization: Token {API_TOKEN}\" <br \/> -H \"X-Secret: {SECRET_TOKEN}\" <br \/> -d '[ \"{\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430}\" ]' <br \/> https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address<\/code><\/p>\n<\/li>\n<\/ol>\n<ol start=\"3\">\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u043b\u0433\u043e\u0442\u0443 \u0438 \u0448\u0438\u0440\u043e\u0442\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441 &#8212;\u00a0 https:\/\/api.openweathermap.org\/data\/2.5\/weather?lat={lat}&amp;lon={lon}&amp;appid={API key}<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a API.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u043f\u0440\u043e\u043c\u043f\u0442 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u0442\u0440\u0435\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439.<\/p>\n<p>\u0420\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<h3>ChatGPT<\/h3>\n<p>*\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 HTML \u0438 JavaScript, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c:*<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">&lt;!DOCTYPE html><br \/>&lt;<strong>html<\/strong> lang=&#187;en&#187;><br \/>&lt;<strong>head<\/strong>><br \/>&lt;<strong>meta<\/strong> charset=&#187;UTF-8&#8243;><br \/>&lt;<strong>meta<\/strong> name=&#187;viewport&#187; content=&#187;width=device-width, initial-scale=1.0&#8243;><br \/>&lt;<strong>title<\/strong>>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&lt;\/<strong>title<\/strong>><br \/>&lt;\/<strong>head<\/strong>><br \/>&lt;<strong>body<\/strong>><br \/>&lt;<strong>h2<\/strong>>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&lt;\/<strong>h2<\/strong>><br \/>&lt;<strong>form<\/strong> id=&#187;weatherForm&#187;><br \/>\u00a0 &lt;<strong>label<\/strong> for=&#187;cityInput&#187;>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430:&lt;\/<strong>label<\/strong>>&lt;<strong>br<\/strong>><br \/>\u00a0 &lt;<strong>input<\/strong> type=&#187;text&#187; id=&#187;cityInput&#187; name=&#187;cityInput&#187;>&lt;<strong>br<\/strong>><br \/>\u00a0 &lt;<strong>button<\/strong> type=&#187;submit&#187;>\u0423\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0433\u043e\u0434\u0443&lt;\/<strong>button<\/strong>><br \/>&lt;\/<strong>form<\/strong>><br \/>&lt;<strong>div<\/strong> id=&#187;weatherResult&#187;>&lt;\/<strong>div<\/strong>><\/p>\n<p>&lt;<strong>script<\/strong>><br \/>document.getElementById(&#8216;weatherForm&#8217;).addEventListener(&#8216;submit&#8217;, <strong>function<\/strong>(event) {<br \/>\u00a0 event.preventDefault(); \/\/ Prevent default form submission<br \/>\u00a0 <br \/>\u00a0 <strong>var<\/strong> city = document.getElementById(&#8216;cityInput&#8217;).value.trim();<br \/>\u00a0 <strong>if<\/strong> (city === &#187;) {<br \/>\u00a0 \u00a0 alert(&#8216;\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u043e\u0434\u0430.&#8217;);<br \/>\u00a0 \u00a0 <strong>return<\/strong>;<br \/>\u00a0 }<br \/>\u00a0 <br \/>\u00a0 fetchCoordinates(city)<br \/>\u00a0 \u00a0 .then(<strong>function<\/strong>(coordinates) {<br \/>\u00a0 \u00a0 \u00a0 <strong>return<\/strong> fetchWeather(coordinates.lat, coordinates.lon);<br \/>\u00a0 \u00a0 })<br \/>\u00a0 \u00a0 .then(<strong>function<\/strong>(weather) {<br \/>\u00a0 \u00a0 \u00a0 displayWeather(weather);<br \/>\u00a0 \u00a0 })<br \/>\u00a0 \u00a0 .catch(<strong>function<\/strong>(error) {<br \/>\u00a0 \u00a0 \u00a0 console.error(&#8216;\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430:&#8217;, error);<br \/>\u00a0 \u00a0 });<br \/>});<\/p>\n<p><strong>function<\/strong> <strong>fetchCoordinates<\/strong>(city) {<br \/>\u00a0 <strong>var<\/strong> apiToken = &#8216;{API_TOKEN}&#8217;;<br \/>\u00a0 <strong>var<\/strong> secretToken = &#8216;{SECRET_TOKEN}&#8217;;<br \/>\u00a0 <br \/>\u00a0 <strong>return<\/strong> fetch(&#8216;https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address&#8217;, {<br \/>\u00a0 \u00a0 method: &#8216;POST&#8217;,<br \/>\u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 &#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 &#8216;Accept&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 &#8216;Authorization&#8217;: &#8216;Token &#8216; + apiToken,<br \/>\u00a0 \u00a0 \u00a0 &#8216;X-Secret&#8217;: secretToken<br \/>\u00a0 \u00a0 },<br \/>\u00a0 \u00a0 body: JSON.stringify([city])<br \/>\u00a0 })<br \/>\u00a0 .then(<strong>function<\/strong>(response) {<br \/>\u00a0 \u00a0 <strong>if<\/strong> (!response.ok) {<br \/>\u00a0 \u00a0 \u00a0 <strong>throw<\/strong> <strong>new<\/strong> Error(&#8216;\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0433\u043e\u0440\u043e\u0434\u0430.&#8217;);<br \/>\u00a0 \u00a0 }<br \/>\u00a0 \u00a0 <strong>return<\/strong> response.json();<br \/>\u00a0 })<br \/>\u00a0 .then(<strong>function<\/strong>(data) {<br \/>\u00a0 \u00a0 <strong>var<\/strong> coordinates = data[0].geo_lat &amp;&amp; data[0].geo_lon ? { lat: data[0].geo_lat, lon: data[0].geo_lon } : <strong>null<\/strong>;<br \/>\u00a0 \u00a0 <strong>if<\/strong> (!coordinates) {<br \/>\u00a0 \u00a0 \u00a0 <strong>throw<\/strong> <strong>new<\/strong> Error(&#8216;\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u043e\u0440\u043e\u0434\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b.&#8217;);<br \/>\u00a0 \u00a0 }<br \/>\u00a0 \u00a0 <strong>return<\/strong> coordinates;<br \/>\u00a0 });<br \/>}<\/p>\n<p><strong>function<\/strong> <strong>fetchWeather<\/strong>(lat, lon) {<br \/>\u00a0 <strong>var<\/strong> apiKey = &#8216;{API_KEY}&#8217;;<br \/>\u00a0 <br \/>\u00a0 <strong>return<\/strong> fetch(`https:\/\/api.openweathermap.org\/data\/2.5\/weather?lat=${lat}&amp;lon=${lon}&amp;appid=${apiKey}`)<br \/>\u00a0 \u00a0 .then(<strong>function<\/strong>(response) {<br \/>\u00a0 \u00a0 \u00a0 <strong>if<\/strong> (!response.ok) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 <strong>throw<\/strong> <strong>new<\/strong> Error(&#8216;\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u043f\u043e\u0433\u043e\u0434\u0435.&#8217;);<br \/>\u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 \u00a0 <strong>return<\/strong> response.json();<br \/>\u00a0 \u00a0 });<br \/>}<\/p>\n<p><strong>function<\/strong> <strong>displayWeather<\/strong>(weather) {<br \/>\u00a0 <strong>var<\/strong> weatherResultDiv = document.getElementById(&#8216;weatherResult&#8217;);<br \/>\u00a0 weatherResultDiv.innerHTML = &#187;;<br \/>\u00a0 <br \/>\u00a0 <strong>var<\/strong> cityName = weather.name;<br \/>\u00a0 <strong>var<\/strong> weatherDescription = weather.weather &amp;&amp; weather.weather[0] ? weather.weather[0].description : &#187;;<br \/>\u00a0 <strong>var<\/strong> temperature = weather.main &amp;&amp; weather.main.temp ? Math.round(weather.main.temp &#8212; 273.15) : &#187;;<br \/>\u00a0 <br \/>\u00a0 <strong>var<\/strong> weatherInfo = document.createElement(&#8216;p&#8217;);<br \/>\u00a0 weatherInfo.textContent = `\u041f\u043e\u0433\u043e\u0434\u0430 \u0432 \u0433\u043e\u0440\u043e\u0434\u0435 ${cityName}: ${weatherDescription}, \u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430: ${temperature}\u00b0C`;<br \/>\u00a0 weatherResultDiv.appendChild(weatherInfo);<br \/>}<br \/>&lt;\/<strong>script<\/strong>><br \/>&lt;\/<strong>body<\/strong>><br \/>&lt;\/<strong>html<\/strong>><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>*\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c `{API_TOKEN}`, `{SECRET_TOKEN}` \u0438 `{API_KEY}` \u043d\u0430 \u0441\u0432\u043e\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 CORS \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.*\u00a0<\/p>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u043d\u0430\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 CORS.\u00a0<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u043e\u0442, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b ChatGPT<\/p>\n<p>*\u0427\u0442\u043e\u0431\u044b \u043e\u0431\u043e\u0439\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 CORS \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a API \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u043f\u0440\u043e\u043a\u0441\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Node.js, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a API `cleaner.dadata.ru` \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442.*<\/p>\n<p>*\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 Node.js:*<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>const<\/strong> express = require(&#8216;express&#8217;);<br \/><strong>const<\/strong> fetch = require(&#8216;node-fetch&#8217;);<br \/><strong>const<\/strong> cors = require(&#8216;cors&#8217;);<\/p>\n<p><strong>const<\/strong> app = express();<br \/><strong>const<\/strong> PORT = process.env.PORT || 3000;<\/p>\n<p>app.use(cors());<\/p>\n<p>app.post(&#8216;\/getCoordinates&#8217;, <strong>async<\/strong> (req, res) => {<br \/>\u00a0 <strong>try<\/strong> {<br \/>\u00a0 \u00a0 <strong>const<\/strong> cityName = req.body.cityName;<br \/>\u00a0 \u00a0 <strong>const<\/strong> response = <strong>await<\/strong> fetch(&#8216;https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address&#8217;, {<br \/>\u00a0 \u00a0 \u00a0 method: &#8216;POST&#8217;,<br \/>\u00a0 \u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Accept&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Authorization&#8217;: &#8216;Token {API_TOKEN}&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;X-Secret&#8217;: &#8216;{SECRET_TOKEN}&#8217;<br \/>\u00a0 \u00a0 \u00a0 },<br \/>\u00a0 \u00a0 \u00a0 body: JSON.stringify([cityName])<br \/>\u00a0 \u00a0 });<\/p>\n<p>\u00a0 \u00a0 <strong>const<\/strong> data = <strong>await<\/strong> response.json();<br \/>\u00a0 \u00a0 <strong>const<\/strong> coordinates = data[0].geo_lat &amp;&amp; data[0].geo_lon ? { lat: data[0].geo_lat, lon: data[0].geo_lon } : <strong>null<\/strong>;<\/p>\n<p>\u00a0 \u00a0 <strong>if<\/strong> (coordinates) {<br \/>\u00a0 \u00a0 \u00a0 res.json(coordinates);<br \/>\u00a0 \u00a0 } <strong>else<\/strong> {<br \/>\u00a0 \u00a0 \u00a0 res.status(404).json({ error: &#8216;Coordinates not found for the provided city name&#8217; });<br \/>\u00a0 \u00a0 }<br \/>\u00a0 } <strong>catch<\/strong> (error) {<br \/>\u00a0 \u00a0 console.error(&#8216;Error:&#8217;, error);<br \/>\u00a0 \u00a0 res.status(500).json({ error: &#8216;Internal Server Error&#8217; });<br \/>\u00a0 }<br \/>});<\/p>\n<p>app.listen(PORT, () => {<br \/>\u00a0 console.log(`Server is running on port ${PORT}`);<br \/>});<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>*\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434\u0435:*<\/p>\n<p>1. *\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 `express` \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430.*<\/p>\n<p>2. *\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 `node-fetch` \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.*<\/p>\n<p>3. *\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 `cors` \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 CORS \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438.*<\/p>\n<p>4. *\u0421\u043e\u0437\u0434\u0430\u043d \u043c\u0430\u0440\u0448\u0440\u0443\u0442 `\/getCoordinates`, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 POST \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0433\u043e\u0440\u043e\u0434\u0430, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API `cleaner.dadata.ru` \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0433\u043e\u0440\u043e\u0434\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0443.*<\/p>\n<p>*\u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0433\u043e\u0440\u043e\u0434\u0430, \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0433\u043e\u0434\u044b \u043a API `api.openweathermap.org`.*<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\">&lt;<strong>html<\/strong> lang=&#187;en&#187;><br \/>&lt;<strong>head<\/strong>><br \/>\u00a0 &lt;<strong>meta<\/strong> charset=&#187;UTF-8&#8243;><br \/>\u00a0 &lt;<strong>meta<\/strong> name=&#187;viewport&#187; content=&#187;width=device-width, initial-scale=1.0&#8243;><br \/>\u00a0 &lt;<strong>title<\/strong>>Weather App&lt;\/<strong>title<\/strong>><br \/>&lt;\/<strong>head<\/strong>><br \/>&lt;<strong>body<\/strong>><br \/>\u00a0 &lt;<strong>h1<\/strong>>Weather App&lt;\/<strong>h1<\/strong>><br \/>\u00a0 &lt;<strong>form<\/strong> id=&#187;cityForm&#187;><br \/>\u00a0 \u00a0 &lt;<strong>label<\/strong> for=&#187;cityName&#187;>Enter city name:&lt;\/<strong>label<\/strong>><br \/>\u00a0 \u00a0 &lt;<strong>input<\/strong> type=&#187;text&#187; id=&#187;cityName&#187; name=&#187;cityName&#187;><br \/>\u00a0 \u00a0 &lt;<strong>button<\/strong> type=&#187;submit&#187;>Get Weather&lt;\/<strong>button<\/strong>><br \/>\u00a0 &lt;\/<strong>form<\/strong>><br \/>\u00a0 &lt;<strong>div<\/strong> id=&#187;weatherData&#187;>&lt;\/<strong>div<\/strong>><\/p>\n<p>\u00a0 &lt;<strong>script<\/strong>><br \/>\u00a0 \u00a0 document.getElementById(&#8216;cityForm&#8217;).addEventListener(&#8216;submit&#8217;, <strong>async<\/strong> (event) => {<br \/>\u00a0 \u00a0 \u00a0 event.preventDefault();<br \/>\u00a0 \u00a0 \u00a0 <br \/>\u00a0 \u00a0 \u00a0 <strong>const<\/strong> cityName = document.getElementById(&#8216;cityName&#8217;).value;<br \/>\u00a0 \u00a0 \u00a0 <strong>const<\/strong> response = <strong>await<\/strong> fetch(&#8216;http:\/\/localhost:3000\/getCoordinates&#8217;, {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 method: &#8216;POST&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#8216;Content-Type&#8217;: &#8216;application\/json&#8217;<br \/>\u00a0 \u00a0 \u00a0 \u00a0 },<br \/>\u00a0 \u00a0 \u00a0 \u00a0 body: JSON.stringify({ cityName })<br \/>\u00a0 \u00a0 \u00a0 });<\/p>\n<p>\u00a0 \u00a0 \u00a0 <strong>const<\/strong> data = <strong>await<\/strong> response.json();<\/p>\n<p>\u00a0 \u00a0 \u00a0 <strong>if<\/strong> (data.error) {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 document.getElementById(&#8216;weatherData&#8217;).textContent = data.error;<br \/>\u00a0 \u00a0 \u00a0 } <strong>else<\/strong> {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 <strong>const<\/strong> weatherResponse = <strong>await<\/strong> fetch(`https:\/\/api.openweathermap.org\/data\/2.5\/weather?lat=${data.lat}&amp;lon=${data.lon}&amp;appid={API key}`);<br \/>\u00a0 \u00a0 \u00a0 \u00a0 <strong>const<\/strong> weatherData = <strong>await<\/strong> weatherResponse.json();<br \/>\u00a0 \u00a0 \u00a0 \u00a0 document.getElementById(&#8216;weatherData&#8217;).textContent = JSON.stringify(weatherData, <strong>null<\/strong>, 2);<br \/>\u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 });<br \/>\u00a0 &lt;\/<strong>script<\/strong>><br \/>&lt;\/<strong>body<\/strong>><br \/>&lt;\/<strong>html<\/strong>><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>*\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 JavaScript \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0433\u043e\u0440\u043e\u0434\u0430, \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u044d\u0442\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0433\u043e\u0434\u044b \u043a API `api.openweathermap.org`.*<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<p>Error [ERR_REQUIRE_ESM]: require() of ES Module &#8230;\/ai\/chat-gpt\/node_modules\/node-fetch\/src\/index.js from &#8230;\/ai\/chat-gpt\/server.js not supported. Instead change the require of index.js in &#8230;\/ai\/chat-gpt\/server.js to a dynamic import() which is available in all CommonJS modules. at Object.&lt;anonymous> (&#8230;\/ai\/chat-gpt\/server.js:50:15) { code: &#8216;ERR_REQUIRE_ESM&#8217; }<\/p>\n<p>\u041f\u0440\u043e\u0448\u0443 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430, \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 axios.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>const<\/strong> express = require(&#8216;express&#8217;);<br \/><strong>const<\/strong> axios = require(&#8216;axios&#8217;);<br \/><strong>const<\/strong> cors = require(&#8216;cors&#8217;);<\/p>\n<p><strong>const<\/strong> app = express();<br \/><strong>const<\/strong> PORT = process.env.PORT || 3000;<\/p>\n<p>app.use(cors());<br \/>app.use(express.json());<\/p>\n<p>app.post(&#8216;\/getCoordinates&#8217;, <strong>async<\/strong> (req, res) => {<br \/>\u00a0 <strong>try<\/strong> {<br \/>\u00a0 \u00a0 <strong>const<\/strong> cityName = req.body.cityName;<br \/>\u00a0 \u00a0 <strong>const<\/strong> response = <strong>await<\/strong> axios.post(&#8216;https:\/\/cleaner.dadata.ru\/api\/v1\/clean\/address&#8217;, [cityName], {<br \/>\u00a0 \u00a0 \u00a0 headers: {<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Content-Type&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Accept&#8217;: &#8216;application\/json&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;Authorization&#8217;: &#8216;Token {API_TOKEN}&#8217;,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 &#8216;X-Secret&#8217;: &#8216;{SECRET_TOKEN}&#8217;<br \/>\u00a0 \u00a0 \u00a0 }<br \/>\u00a0 \u00a0 });<\/p>\n<p>\u00a0 \u00a0 <strong>const<\/strong> data = response.data;<br \/>\u00a0 \u00a0 <strong>const<\/strong> coordinates = data[0].geo_lat &amp;&amp; data[0].geo_lon ? { lat: data[0].geo_lat, lon: data[0].geo_lon } : <strong>null<\/strong>;<\/p>\n<p>\u00a0 \u00a0 <strong>if<\/strong> (coordinates) {<br \/>\u00a0 \u00a0 \u00a0 res.json(coordinates);<br \/>\u00a0 \u00a0 } <strong>else<\/strong> {<br \/>\u00a0 \u00a0 \u00a0 res.status(404).json({ error: &#8216;Coordinates not found for the provided city name&#8217; });<br \/>\u00a0 \u00a0 }<br \/>\u00a0 } <strong>catch<\/strong> (error) {<br \/>\u00a0 \u00a0 console.error(&#8216;Error:&#8217;, error);<br \/>\u00a0 \u00a0 res.status(500).json({ error: &#8216;Internal Server Error&#8217; });<br \/>\u00a0 }<br \/>});<\/p>\n<p>app.listen(PORT, () => {<br \/>\u00a0 console.log(`Server is running on port ${PORT}`);<br \/>});<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043d\u0443\u0436\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e\u043f\u0440\u043e\u0448\u0443 \u043e\u0442\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 API.<\/p>\n<p>*\u0412\u044b\u0432\u0435\u0434\u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 API, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0430\u043a\u0430\u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0433\u043e\u0434\u0430, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u0435\u0442\u0440\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435*<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"\"><\/figure>\n<h3><\/h3>\n<h3>Phind<\/h3>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u044e \u043f\u0440\u043e\u043c\u043f\u0442 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0436\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435. Phind \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u043b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c html \u0438 js \u043a\u043e\u0434 \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0447\u0442\u043e \u0440\u0430\u0434\u0443\u0435\u0442.<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-373628","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/373628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=373628"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/373628\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}