Auto Running HTML files in server with for custom folder
Asked by MOHAMMED SHAHID about a year ago
Hi All, How to auto-run the server for custom folder created for HTML. Any specific cmd ? any config in .cmrc file ?
I tried with adding 'folderName/fileName.html' in tabs of .cmrc file, but it did'nt work.
I tried to reload the server, that as well did'nt fix. Any idea, what I might be doing wrong ? Thanks
1 Answer
We use static-server npm package to server html files.
By simply typing static-server
on the playground terminal you can iniate the http server, by doing this the static server takes the defualt arguments i.e. port = 3000 and file = index.html
But, in codedamn playgrounds only the ports 1337
and 1338
are accessbile by users, so you have to define the port using the -p
or --port
flag
Also to disable the static server from showing cached response we add the flag --no-cache
So now to start the http server at a different html page you can make use of the flag -i
or --index
followed by the file location
So your complete command would be
static-server -p 1337 --no-cache --index folderName/filename.html
You can add the same line in your .cdmrc
file as well
tabs: ['folderName/filename.html']
terminal-one: static-server -p 1337 --no-cache --index folderName/filename.html
If you want to know more about how to use our .cdmrc
file you can read our blogpost
Hope this helps you