My project is based on the Quick Start Demo for the K60 where it used the httpd web server framework and accesses web pages in the SDcard which worked fine. I updated my project using the httpsrv framework from the httpsrv example project and everything works fine (serving web pages from flash is good) but any web pages on the SDcard come up as 404 Page Not Found. I see there is a root directory alias structure HTTPD_ROOT_DIR_STRUCT root_dir[] in the httpd web server which I have changed to const HTTPSRV_ALIAS http_aliases[] and kept the contents of the structure the same. There's also a function to check if the SDcard is installed with a signature static void sdcard_status_fn(HTTPD_SESSION_STRUCT *session) which I have changed to static _mqx_int sdcard_status_fn(HTTPSRV_SSI_PARAM_STRUCT* param). I think I've got this function coded fine and everything compiles fine, just web pages on the SDcard come up as 404 Page Not Found. Anything else I'm missing using the httpsrv framework and accessing web pages on the SDcard?
Thanks,
Gene
Solved! Go to Solution.
Hi Gene,
just to be sure. You are accessing webpages on sdcard from your browser through URL that looks like this: http://BOARD_IP_ADDRESS/sdcard/WEB_PAGE_NAME.html
? And this sdcard is mounted as disk "a:" in your configuration, right? If that is true, then your aliases should look like this:
const HTTPSRV_ALIAS http_aliases[] = {{ "/sdcard/", "a:\\" },{ NULL, NULL }};
Best regards,
Karel
Hi,
can you please share source code of your application with me? Problem might be with alias definitions. It should look like this:
HTTPSRV_ALIAS http_aliases[] = { {"/usb/", "c:\\"}, {NULL, NULL} };
First variable ("/usb/") is part of URI which will be replaced by second variable ("c:\\") when server looks for a file in filesystem. Also please note the backslashes and make sure you have set them in same way.
Best regards
Karel.
Thanks Karel.
The alias definition you gave works for the web-hvac project, where web pages are stored on a USB stick. In the K60 Quick Start Demo, the web pages are stored on the SDcard which is very similar, yet may have slight differences because it connects through the SD driver rather than the USB stack.
Here is my code, which is identical to the working Quick Start Demo code, but with HTTPD_ROOT_DIR_STRUCT root_dir[] replaced with HTTPSRV_ALIAS http_aliases[].
const HTTPSRV_ALIAS http_aliases[] = {
{ "", "tfs:" }, //Internal flash with Trivial File System
{ "sdcard", "a:" }, //SDCard as a: partition drive
{ 0, 0 }
};
I also tried { "/sdcard/", "a:\\" } but still got 404 Page Not Found.
Thank you!
Hi Gene,
just to be sure. You are accessing webpages on sdcard from your browser through URL that looks like this: http://BOARD_IP_ADDRESS/sdcard/WEB_PAGE_NAME.html
? And this sdcard is mounted as disk "a:" in your configuration, right? If that is true, then your aliases should look like this:
const HTTPSRV_ALIAS http_aliases[] = {{ "/sdcard/", "a:\\" },{ NULL, NULL }};
Best regards,
Karel
Karel,
You are correct. I added your alias entry and I had to remove the alias { "", "tfs:" } and everything works fine.
Thank you Karel!
Hi,
I am glad it works for you :smileyhappy:
Best regards,
Karel