brew install nginx
/etc/hosts
127.0.0.1 admin.local
const puppeteer = require('puppeteer') | |
const urls = [ | |
'https://ticket.rzd.ru/searchresults/v/1/5a3244bc340c7441a0a556ca/5a323c29340c7441a0a556bb/2022-06-28?aim=social-media&trainNumber=759%D0%90', | |
'https://ticket.rzd.ru/searchresults/v/1/5a3244bc340c7441a0a556ca/5a323c29340c7441a0a556bb/2022-06-28?aim=social-media&trainNumber=761%D0%90', | |
] | |
const main = async () => { | |
const browser = await puppeteer.launch({ headless: false }) | |
const page = await browser.newPage() |
brew install nginx
/etc/hosts
127.0.0.1 admin.local
Vue.componentExternal = function(name, options) { | |
Vue.component(name, function(resolve) { | |
fetch(`components/${name}/${name}.html`) | |
.then(response => response.text()) | |
.then(template => { | |
resolve(Object.assign(options, { | |
template: template | |
})) | |
}) | |
}) |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
<style> | |
.form-signin { | |
max-width: 330px; | |
margin: auto; | |
margin-top: 100px; | |
} | |
</style> | |
<div class="container"> |
Use BrowserSync as proxy with serving local files.
Проблема заключается в том, что при вызове callback() переменная request всегда имеет значение /populations
. Это происходит из-за асинхронного вызова функции callback().
Есть два способа решения проблемы:
В обоих случаях переменная request сохраняет значение, которое она имела на момент вызова функции getData().
В файле alternative.js сделан вывод популяции страны.
var express = require('express') | |
var request = require('request') | |
var app = express() | |
app.get('/', function(req, res) { | |
var src = req.query.src | |
res.header('Access-Control-Allow-Origin', '*') | |
if (!src) { res.send(''); return } |