Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » [Solved]Can't show favicon.ico in Skylark if root path is not Null
[Solved]Can't show favicon.ico in Skylark if root path is not Null [message #36868] Sun, 15 July 2012 13:03 Go to next message
kasome is currently offline  kasome
Messages: 78
Registered: July 2008
Location: Taiwan
Member
Hello,

In order to display the favicon.ico (by Firefox, Opera, GoogleChrome browser), I try to modify the example Skylark01 in upp\tutorial, as the following,

#include <Web/Web.h>
#include <Draw/Draw.h>
#include <plugin/png/png.h>
#include <Skylark/Skylark.h>

using namespace Upp;

#define IMAGECLASS ICON
#define IMAGEFILE  <UppSkylark.iml>
#include <Draw/iml.h>

#if( defined(flagMSC) && defined(flagDEBUG) )
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif

SKYLARK( HomePage, "" ) {
	http.ContentType( HttpTextHtml(CHARSET_UTF8) ) << "<html><body>Hello world!</body></html>";
}

SKYLARK( Param, "*/param" ) {
	http.ContentType( HttpTextHtml(CHARSET_UTF8) ) << "<html><body>Parameter: " << http[0] << "</html></body>";
}

SKYLARK( Params, "params/**" ) {
	http.ContentType( HttpTextHtml(CHARSET_UTF8) );
	http << "<html><body>Parameters: ";
	for( int i=0; i<http.GetParamCount(); ++i ) {
		http << http[i] << " ";
	}
	http << "</html></body>";
}

SKYLARK( FavIcon, "favicon.ico" ) {
	http.ContentType( HttpImage("x-icon") ) << PNGEncoder().SaveString(ICON::Upp());
}

SKYLARK( CatchAll, "**" ) {
	http.Redirect(HomePage);
}

class MyApp : public SkylarkApp {
public:
	MyApp() {
//		root = Null;
//		root = "myapp";		
	#ifdef flagDEBUG
		prefork = 0;
		use_caching = false;
	#endif
	}
};

CONSOLE_APP_MAIN {
#ifdef flagMSC
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

#ifdef flagDEBUG
	Ini::skylark_log = true;
	StdLogSetup( LOG_FILE | LOG_COUT );	
#endif
	
	MyApp().Run();
}


And it works if the root path is only Null (In MyApp constructor)

when i connect to http://127.0.0.1:8001/ .

But when the root path is not Null, like root = "myapp"; ,

then how could i handle the request for

http://127.0.0.1:8001/favicon.ico ¡H

[Updated on: Tue, 17 July 2012 04:28]

Report message to a moderator

Re: Can't show favicon.ico in Skylark if root path is not Null [message #36869 is a reply to message #36868] Sun, 15 July 2012 19:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Good point. Added feature that '/' at the start of path avoids prepending 'root':


SKYLARK(Favicon, "/favicon.ico")
{
	http.ContentType("image/png") << LoadFile(GetDataFile("favicon.png"));
}


Mirek
Re: Can't show favicon.ico in Skylark if root path is not Null [message #36886 is a reply to message #36869] Tue, 17 July 2012 04:28 Go to previous message
kasome is currently offline  kasome
Messages: 78
Registered: July 2008
Location: Taiwan
Member
Well done. Thanks. Smile
Previous Topic: Http file download question
Next Topic: Skylark logs failure in accept()
Goto Forum:
  


Current Time: Wed Apr 17 01:00:54 CEST 2024

Total time taken to generate the page: 0.02565 seconds