Si elle aide tous ceux que j'écrit un script rapide pour extraire l'URL aléatoire généré dans le nœud:
Il fait hypothèse que vous êtes seulement intéressé par l'URL sécurisée.
const fetch = require('node-fetch')
fetch('http://localhost:4040/api/tunnels')
.then(res => res.json())
.then(json => json.tunnels.find(tunnel => tunnel.proto === 'https'))
.then(secureTunnel => console.log(secureTunnel.public_url))
.catch(err => {
if (err.code === 'ECONNREFUSED') {
return console.error("Looks like you're not running ngrok.")
}
console.error(err)
})
Si vous vouliez tous les tunnels:
const fetch = require('node-fetch')
fetch('http://localhost:4040/api/tunnels')
.then(res => res.json())
.then(json => json.tunnels.map(tunnel => tunnel.public_url))
.then(publicUrls => publicUrls.forEach(url => console.log(url)))
.catch(err => {
if (err.code === 'ECONNREFUSED') {
return console.error(
"Looks like you're not running ngrok."
)
}
console.error(err)
})
comment puis-je faire avec python3 avec seulement urllib.urlopen? Je ne veux pas 1. appeler la commande externe curl, 2. rediriger vers un fichier .. Merci – f126ck