Node.js 获取项目根目录
- May 6, 2016 3:22 PM
- node.js6
- 6714
介绍一个小技巧获取node.js项目根目录,这个技巧非常实用。
假设我们的js文件写在server目录中,但是我们的资源文件存储在app/img目录中。如下图,我们需要在server/index.js文件中使用fs读取app/img/favicon.ico文件。
在node.js只提供了一个__dirname
全局变量。通过__dirname
可以获得“C:\wwwroot\yidata\server”
。这时需要用到path。
👀️
牛逼
大哥,能不能教我用00.0.1刷小米路由器4?我自己尝试了没有搞好,001版本还没有弄太懂
看样子并没有报错。可以尝试断电重启,然后再试一次。有网友通过这个方法成功了。
小米路由器4telnet无法连接,请问大神有没有办法解决?路由固件已从2.26.175降级为2.26.127,这两个固件都卡在telnet连接上
fly@fly:~/Desktop/Python-3.9.0/OpenWRTInvasion$ python3 remote_command_execution_vulnerability.py Router IP address: 192.168.31.1 stok: f9fc3d2201f28138c3b4b9228f6c4434
router_ip_address: 192.168.31.1 stok: f9fc3d2201f28138c3b4b9228f6c4434
start uploading config file... start exec command... done! Now you can connect to the router using telnet (user: root, password: none) In MacOS, execute in the terminal: telnet 192.168.31.1
fly@fly:~/Desktop/Python-3.9.0/OpenWRTInvasion$ telnet 192.168.31.1 Trying 192.168.31.1... telnet: Unable to connect to remote host: Connection refused