Is there any way to set what page the webserver serves as a default homepage programatically? I am looking to switch between two default pages via a variable stored in RAM.
Thanks in advance.
Conditional default page? [SBL2e]
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: Conditional default page? [SBL2e]
I can't quite remember the details, but I have a dim recollection that if here is an html folder on an SD card with and index.htm file in it, then that SD-based file will be used instead of the regular file in the project html directory. That said I just tried it w/o success, but I still remember doing something like this once.... Anyone recollect something similar?
Re: Conditional default page? [SBL2e]
My question is more regarding changing the default_page variable in htmldata.cpp on the fly. Is there any way to change how that variable is outputted from comphtml? Currently it is a const, which poses a bit of an issue.
Thanks.
Thanks.
Re: Conditional default page? [SBL2e]
You can do that with the standard tcp stack, but not the single-chip stack used in the sbl2e. There was another thread in here somewhere (last week I think) asking how to parse the requested web page in the url, and I think the answer was that the SBL2e with 32k doesn't have enough memory to do that.
Re: Conditional default page? [SBL2e]
I guess I'm stuck with a RedirectResponse based on a variable. Thanks.
Re: Conditional default page? [SBL2e]
The SBL2E has a function that is setup to do exactly this.
#include <htmlfiles.h>
//File records definition of this is in htmlfiles.h
extern const HTML_FILE_RECORD file_record[];
//Number of file records.
extern const unsigned n_file_record;
//To figure out which file record you want to return
//You can either hard code it if the file order in the html subdir never changes
//Or on startup you can scan the records above to find the
//files with specific names.
//The structure of the HTML_FILE_RECORD is defined
//In htmlfiles.h
//The file name is in the member constchar * fname
//so the name of the first file would be:
//file_record[0].fname....
//2nd
//file_record[1].fname
//
//
//last one:
//filerecord[n_file_rcord-1].fname
//All HTML response in the system are by file num in the file record.
//This optional function can take the chosen file record number and allow you to
//change which one is returned.
int MyOverride(int filenum)
{
//return the file record number you would like to serve.
return filenum;
}
//The somewhere in initalization...
//tell the system you have an override function....
pOverrideGet=MyOverride;
#include <htmlfiles.h>
//File records definition of this is in htmlfiles.h
extern const HTML_FILE_RECORD file_record[];
//Number of file records.
extern const unsigned n_file_record;
//To figure out which file record you want to return
//You can either hard code it if the file order in the html subdir never changes
//Or on startup you can scan the records above to find the
//files with specific names.
//The structure of the HTML_FILE_RECORD is defined
//In htmlfiles.h
//The file name is in the member constchar * fname
//so the name of the first file would be:
//file_record[0].fname....
//2nd
//file_record[1].fname
//
//
//last one:
//filerecord[n_file_rcord-1].fname
//All HTML response in the system are by file num in the file record.
//This optional function can take the chosen file record number and allow you to
//change which one is returned.
int MyOverride(int filenum)
{
//return the file record number you would like to serve.
return filenum;
}
//The somewhere in initalization...
//tell the system you have an override function....
pOverrideGet=MyOverride;