res.sendFile absolute path

The express.static middleware is separate from res.sendFile, so initializing it with an absolute path to your public directory won’t do anything to res.sendFile. You need to use an absolute path directly with res.sendFile. There are two simple ways to do it: res.sendFile(path.join(__dirname, ‘../public’, ‘index1.html’)); res.sendFile(‘index1.html’, { root: path.join(__dirname, ‘../public’) }); Note: __dirname returns the directory …

Read more

How do I find the location of the executable in C? [duplicate]

To summarize: On Unixes with /proc really straight and realiable way is to: readlink(“/proc/self/exe”, buf, bufsize) (Linux) readlink(“/proc/curproc/file”, buf, bufsize) (FreeBSD) readlink(“/proc/self/path/a.out”, buf, bufsize) (Solaris) On Unixes without /proc (i.e. if above fails): If argv[0] starts with “https://stackoverflow.com/” (absolute path) this is the path. Otherwise if argv[0] contains “https://stackoverflow.com/” (relative path) append it to cwd …

Read more

Finding the path of the program that will execute from the command line in Windows

Use the where command. The first result in the list is the one that will execute. C:\> where notepad C:\Windows\System32\notepad.exe C:\Windows\notepad.exe According to this blog post, where.exe is included with Windows Server 2003 and later, so this should just work with Vista, Win 7, et al. On Linux, the equivalent is the which command, e.g. …

Read more