bonjour à tou.te.s
j'utilise Express et Ejs, et tout fonctionne nickel
linux manjaro, en local
mais ( ben oui, sinon je ne serais pas là )
si le navigateur ( n'importe lequel ) est déjà actif
et ce, quel que soit le port utilisé,
une erreur se produit :
Unable to connect
can’t establish a connection to the server at localhost:13579.
The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Waterfox is permitted to access the Web.
edit : oubli de l'extrait de la source
run.js
main.html
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 const proenf=require('child_process'); const ejs=require('ejs'); const app=require('express')(); app.engine('html',ejs.renderFile); app.set('views',__dirname+'/'); const hote='localhost', port=12345; app.listen(port,hote, function() { proenf.exec( 'xdg-open http://'+hote+':'+port, function() { process.exit(); });}); app.get('/',function(requete,reponse) { reponse.render( 'main.html', { 'repapp':__dirname } );});
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <!DOCTYPE html> <html lang='fr'> <head> <title>main.html</title> <meta charset='utf-8'> </head> <body> répertoire de l'application : <%=repapp%> </body> </html>
je fais quoi comme bétise ?
merci d'avance
Partager