Re: [Cppcms-users] How to add second web page in CppCMS application?
Brought to you by:
artyom-beilis
From: 陈抒 <csf...@gm...> - 2011-11-17 11:33:24
|
It seems that my application based on CppCMS didn't receive any request. 陈抒 Best regards http://blog.csdn.net/sheismylife On Thu, Nov 17, 2011 at 7:15 PM, 陈抒 <csf...@gm...> wrote: > Hello,Artyom: > When I tried to use CppCMS with Nginx,the jsonp call doesn't work. > I look into my Nginx log files and list some info below: > > in access.log > 124.207.104.18 - - [17/Nov/2011:04:47:23 -0600] "GET > /save_email?content=send%20email%20test%20&callback=jQuery15107370382682420313_1321523058476&_=1321526506452 > HTTP/1.1" 404 \ > 168 "-" "curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e > zlib/1.2.3.4 libidn/1.22 librtmp/2.3" > > in error.log > > 2011/11/17 04:47:23 [error] 2019#0: *46 open() > "/usr/nginx/html/save_email" failed (2: No such file or directory), client: > 124.207.104.18, server: localhost, request: "GET /sav\ > e_email?content=send%20email%20test%20&callback=jQuery15107370382682420313_1321523058476&_=1321526506452 > HTTP/1.1", host: "www.cmltechnology.com" > > If I don't use Nginx and FastCGI with CppCMS,my jsonp function > works,here is my JavaScript function definition: > <script type="text/javascript"> > function save_email(){ > var message=document.getElementById("email_content").value; > $.ajax({ > "url": "http://www.cmltechnology.com/save_email?content= > "+message+"&callback=?", > type:"get", > dataType:"jsonp", > jsonp:"callback", > success:function(data){ > alert(data.result); > }, > error:function(err){ > alert(err.result); > }, > complete: function(msg){ > } > }); > } > </script> > > > Any idea? > > > > 陈抒 > Best regards > http://blog.csdn.net/sheismylife > > > > On Sun, Oct 2, 2011 at 9:32 AM, chenshu <csf...@gm...> wrote: > >> On 10/01/2011 10:10 PM, Artyom Beilis wrote: >> >>> Take a look on: >>> >>> http://art-blog.no-ip.info/**wikipp/en/page/cppcms_1x_**config#views<http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x_config#views> >>> >>> If you use more then one skin you need either: >>> >>> 1. To specify skin name explicitly render("myskin","message",**content) >>> >>> 2. To specify the default skin in configuration file. >>> >>> Also I'd suggest following: >>> >>> 1. If you have pages that have same base view (like same "theme") >>> then put them into same skin. Use some basic template that defines >>> general appearance of the page and extend it with inheritance >>> >>> to specific purposes. >>> 2. For totally different pages like "administrative interface" and >>> "public interface" use different skins. >>> >>> See: http://art-blog.no-ip.info/**wikipp/en/page/cppcms_1x_** >>> templates_gen<http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x_templates_gen> >>> Artyom Beilis >>> -------------- >>> CppCMS - C++ Web Framework: http://cppcms.sf.net/ >>> CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/**cppdb/<http://cppcms.sf.net/sql/cppdb/> >>> >>> >>> ----- Original Message ----- >>> >>>> From: chenshu<csf...@gm...> >>>> To: cppcms-users@lists.**sourceforge.net<cpp...@li...> >>>> Cc: >>>> Sent: Saturday, October 1, 2011 3:26 PM >>>> Subject: [Cppcms-users] How to add second web page in CppCMS >>>> application? >>>> >>>> Hello, >>>> I have set up one simple web application >>>> here:http://www.**cmlelectronics.com:8080/kaimei<http://www.cmlelectronics.com:8080/kaimei> >>>> It only has one page and works.Now I try to add another new page for >>>> registering new user. >>>> I create register_client.tmpl in src folder,configure my CMakeLists.txt >>>> like so: >>>> >>>> //for my first page >>>> add_custom_command( >>>> OUTPUT ${CMAKE_SOURCE_DIR}/src/my_**skin.cpp >>>> COMMAND cppcms_tmpl_cc ${CMAKE_SOURCE_DIR}/src/**welcome.tmpl -o >>>> ${CMAKE_SOURCE_DIR}/src/my_**skin.cpp >>>> DEPENDS welcome.tmpl >>>> ) >>>> >>>> //for my second page >>>> add_custom_command( >>>> OUTPUT ${CMAKE_SOURCE_DIR}/src/**register_client.cpp >>>> COMMAND cppcms_tmpl_cc ${CMAKE_SOURCE_DIR}/src/** >>>> register_client.tmpl >>>> -o ${CMAKE_SOURCE_DIR}/src/**register_client.cpp >>>> DEPENDS register_client.tmpl >>>> ) >>>> >>>> AUX_SOURCE_DIRECTORY(${CMAKE_**SOURCE_DIR}/src CPP_LIST) >>>> add_executable(main ${CPP_LIST} my_skin.cpp register_client.cpp) >>>> >>>> The following is my config.js: >>>> >>>> { >>>> "service" : { >>>> "ip":"0.0.0.0", >>>> "api" : "http", >>>> "port" : 8080 >>>> }, >>>> "db" : { >>>> "name" : "fucai", >>>> "ip" : "myip", >>>> "user": "myusr", >>>> "password":"mypwd" >>>> }, >>>> "http" : { >>>> "script_names" : ["/kaimei"] >>>> }, >>>> "uri_config":{ >>>> "base":"http://www.**cmlelectronics.com<http://www.cmlelectronics.com> >>>> ", >>>> "jsonp":"http://localhost:8080**" >>>> } >>>> } >>>> >>>> >>>> I defined one class hello: >>>> class hello : public cppcms::application { >>>> public: >>>> hello(cppcms::service&srv); >>>> void save_email(std::string content); >>>> void welcome(std::string url); >>>> void register_client(std::string url); >>>> >>>> private: >>>> content::message c_; >>>> }; >>>> >>>> >>>> >>>> hello::hello(cppcms::service&**srv):cppcms::application(srv){ >>>> dispatcher().assign("/welcome" ,&hello::welcome , this , 1); >>>> dispatcher().assign("/**register" ,&hello::register_client , >>>> this , 2); >>>> dispatcher().assign("/save_**email?(.+)" ,&hello::save_email , >>>> >>>> this , 3); >>>> configuration& config = app_singleton_holder::** >>>> Instance().config(); >>>> c_.base_uri=config.base_uri; >>>> c_.jsonp= config.jsonp; >>>> } >>>> >>>> void hello::welcome(std::string url){ >>>> render("message",c_); >>>> } >>>> >>>> >>>> void hello::register_client(std::**string url){ >>>> render("message2",c_); >>>> } >>>> >>>> >>>> >>>> >>>> But always get the following error message when I want to open my pages >>>> via http://localhost:8080/kaimei/**welcome<http://localhost:8080/kaimei/welcome>or >>>> http://localhost:8080/kaimei/**register<http://localhost:8080/kaimei/register> >>>> >>>> 2011-10-01 12:22:14 GMT; cppcms, error: Caught exception [There is no >>>> such skin:] >>>> 0x7fa68cc3b434: cppcms::cppcms_error::cppcms_**error(std::string >>>> const&) + >>>> 0x64 in /usr/lib/libcppcms.so.1 >>>> 0x7fa68cc7e907: cppcms::views_pool::render(**std::string, std::string, >>>> std::ostream&, cppcms::base_content&) + 0x12e7 in >>>> /usr/lib/libcppcms.so.1 >>>> 0x7fa68cc65875: cppcms::application::render(**std::string, >>>> cppcms::base_content&) + 0x85 in /usr/lib/libcppcms.so.1 >>>> 0x40d866: hello::welcome(std::string) + 0x50 in ./main >>>> 0x40ef55: >>>> cppcms::url_dispatcher::**binder1<hello>::operator()(**std::string) >>>> const + >>>> 0x9b in ./main >>>> 0x40ede5: booster::function<void (std::string)>::callable_impl<**void, >>>> cppcms::url_dispatcher::**binder1<hello> >::call(std::string) + 0x3b >>>> in >>>> ./main >>>> 0x7fa68cc6b579: ??? + 0x8cc6b579 in /usr/lib/libcppcms.so.1 >>>> 0x7fa68cc68a6d: cppcms::url_dispatcher::**dispatch(std::string) + 0x8d >>>> in >>>> /usr/lib/libcppcms.so.1 >>>> 0x7fa68cc30884: cppcms::application::main(std:**:string) + 0x24 in >>>> /usr/lib/libcppcms.so.1 >>>> 0x7fa68cc5e12e: >>>> cppcms::http::context::**dispatch(booster::intrusive_** >>>> ptr<cppcms::application>, >>>> >>>> std::string, bool) + 0x6e in /usr/lib/libcppcms.so.1 >>>> 0x7fa68cc5ffec: booster::function<void ()>::callable_impl<void, >>>> cppcms_boost::_bi::bind_t<**void, void >>>> (*)(booster::intrusive_ptr<**cppcms::application>, std::string, bool), >>>> cppcms_boost::_bi::list3<**cppcms_boost::_bi::value<** >>>> booster::intrusive_ptr<cppcms:**:application> >>>> >>>> , cppcms_boost::_bi::value<std::**string>, >>>>> >>>> cppcms_boost::_bi::value<bool> > > >::call() + 0x4c in >>>> /usr/lib/libcppcms.so.1 >>>> 0x7fa68cc61112: cppcms::impl::thread_pool::**worker() + 0x82 in >>>> /usr/lib/libcppcms.so.1 >>>> 0x7fa68b256d2e: booster_thread_func + 0x1e in >>>> /usr/local/lib/libbooster.so.0 >>>> 0x7fa68b696d8c: ??? + 0x8b696d8c in /lib/x86_64-linux-gnu/** >>>> libpthread.so.0 >>>> 0x7fa68b99404d: clone + 0x6d in /lib/x86_64-linux-gnu/libc.so.**6 >>>> (http_context.cpp:150) >>>> >>>> >>>> welcome.tmpl file's content: >>>> >>>> <% c++ #include "content.h" %> >>>> <% skin my_skin %> >>>> <% view message uses content::message %> >>>> <% template render() %> >>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >>>> "http://www.w3.org/TR/xhtml1/**DTD/xhtml1-transitional.dtd<http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> >>>> "> >>>> <html xmlns="http://www.w3.org/1999/**xhtml<http://www.w3.org/1999/xhtml> >>>> "> >>>> <head> >>>> <meta http-equiv="Content-Type" content="text/html; >>>> charset=utf-8" /> >>>> >>>> ... >>>> >>>> >>>> register.tmpl file's content: >>>> >>>> <% c++ #include "content.h" %> >>>> <% skin client %> >>>> <% view message2 uses content::message %> >>>> <% template render() %> >>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >>>> "http://www.w3.org/TR/html4/**loose.dtd<http://www.w3.org/TR/html4/loose.dtd> >>>> "> >>>> <html> >>>> <head> >>>> <script src="http://c >>>> >>>> ...... >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> ------------------------------**------------------------------** >>>> ------------------ >>>> All of the data generated in your IT infrastructure is seriously >>>> valuable. >>>> Why? It contains a definitive record of application performance, >>>> security >>>> threats, fraudulent activity, and more. Splunk takes this data and makes >>>> sense of it. IT sense. And common sense. >>>> http://p.sf.net/sfu/splunk-**d2dcopy2<http://p.sf.net/sfu/splunk-d2dcopy2> >>>> ______________________________**_________________ >>>> Cppcms-users mailing list >>>> Cppcms-users@lists.**sourceforge.net<Cpp...@li...> >>>> https://lists.sourceforge.net/**lists/listinfo/cppcms-users<https://lists.sourceforge.net/lists/listinfo/cppcms-users> >>>> >>>> ------------------------------**------------------------------** >>> ------------------ >>> All of the data generated in your IT infrastructure is seriously >>> valuable. >>> Why? It contains a definitive record of application performance, security >>> threats, fraudulent activity, and more. Splunk takes this data and makes >>> sense of it. IT sense. And common sense. >>> http://p.sf.net/sfu/splunk-**d2dcopy2<http://p.sf.net/sfu/splunk-d2dcopy2> >>> ______________________________**_________________ >>> Cppcms-users mailing list >>> Cppcms-users@lists.**sourceforge.net<Cpp...@li...> >>> https://lists.sourceforge.net/**lists/listinfo/cppcms-users<https://lists.sourceforge.net/lists/listinfo/cppcms-users> >>> >> Oh,thanks.It works now. >> > > |