我刚刚开始使用wt(使用c++绑定)进行开发。到目前为止,我能做的就是阅读很少的文档和一些示例程序(用c++和wt编写)。
之后,我在我的机器上安装了wt,并尝试运行其中一个演示程序。
hello.cc
#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>
class HelloApplication : public Wt::WApplication
{
public:
HelloApplication(const Wt::WEnvironment& env);
private:
Wt::WLineEdit *nameEdit_;
Wt::WText *greeting_;
void greet();
};
HelloApplication::HelloApplication(const Wt::WEnvironment& env)
: Wt::WApplication(env)
{
setTitle("Hello world");
root()->addWidget(new Wt::WText("Your name, please ? "));
nameEdit_ = new Wt::WLineEdit(root());
Wt::WPushButton *button = new Wt::WPushButton("Greet me.", root());
root()->addWidget(new Wt::WBreak());
greeting_ = new Wt::WText(root());
button->clicked().connect(this, &HelloApplication::greet);
}
void HelloApplication::greet()
{
greeting_->setText("Hello there, " + nameEdit_->text());
}
Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
return new HelloApplication(env);
}
int main(int argc, char **argv)
{
return Wt::WRun(argc, argv, &createApplication);
}我遵守了这段代码
g++ -o hello hello.cc -lwthttp -lwt我可以成功地运行这个服务器应用程序,以便在本地主机上运行它。
[manmatha@manmatha Lab]$ su
Password:
[root@manmatha Lab]# ./hello --docroot . --http-address 127.0.0.1 --http-port 9090
[2013-Jun-14 13:58:08.585419] 5066-[info] "WServer/wthttp:initializing built-in wthttpd"
[2013-Jun-14 13:58:08.590955] 5066-[info] "wthttp:started server: http://127.0.0.1:9090"问题是当我键入
本地主机::9090
在本地机器上因特网浏览器的地址栏上,任何东西都不会出现。在这种情况下,我的具体问题是如何启动一个wt客户??无菌
发布于 2013-10-03 23:38:03
试试127.0.0.1:9090
您在命令行上指定了127.0.0.1,因此在浏览器的地址栏中键入它。这是一个特定的Wt嵌入式http服务器。
发布于 2015-07-09 08:36:27
您必须在命令行参数中提到--deploy-path变量。试试这个--http-address 127.0.0.1 --http-port 9090 --deploy-path=/hello --docroot=.
在浏览器类型http://localhost:9090/hello中
https://stackoverflow.com/questions/17104423
复制相似问题