C++ Web Programming
一般的网关接口或者CGI,就是一个标准的集合。它定义信息怎样再问吧server和一般脚本间的交换。
CGI的说明书是由NCSA维护,NCSA定义CGI的范畴:一般的网关接口或者CGI是外部网关程序的一个标准,它与信息server交互。当前的CGI版本号是CGI/3.2.9,兴许版本号还在开发中。
一般的网关程序(CGI)是一个标准协议,它可以使应用程序(称之为CGI程序或者CGI脚本)与Webserver和client进行交互。
这些CGI程序可以使用Python、PERL、Shell,C或者C++等编写。
以下介绍一个实例,依据这个实例来说明,怎样使用CGI。
首先,必须配置HTTPserver,这里。我们选择ApacheHttpd作为HTTP协议的server。CGI设置例如以下:
#change the directoryRootvariable in httpd.conf file
DocumentRoot"/usr/local/apache-2.4.9/htdocs"
#set theaccess control
<Directory"/usr/local/apache-2.4.9">
…
#enable the cgi module
LoadModule cgid_module modules/mod_cgid.so
#set the directoryproperties
<Directory "/usr/local/apache-2.4.9/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory> <Directory "/usr/local/apache-2.4.9/cgi-bin">
Options All
</Directory>
编写一个C++的CGI程序,并编译它得到cpp.cgi文件。改变这个文件的全部权限,使用命令“chmod 755 cpp.cgi”。
cpp.cpp文件
#include <iostream>
using namespace std; int main ()
{ cout << "Content-type:text/html\r\n\r\n";
cout << "<html>\n";
cout << "<head>\n";
cout << "<title>C++ CGI Welcome you</title>\n";
cout << "</head>\n";
cout << "<body>\n";
cout << "<h2>Congratulation, you enter into the world of CGI.</h2>\n";
cout << "</body>\n";
cout << "</html>\n"; return 0;
}
将编译后的cgi文件放置指定的路径(/usr/local/apache-2.4.9/cgi-bin)下。启动httpd服务。浏览页面:
http://hadoop-master/cgi-bin/cpp.cgi
版权声明:本文博客原创文章。博客,未经同意,不得转载。
C++ Web Programming的更多相关文章
- Introduction to ASP.NET Web Programming Using the Razor Syntax (C#)
1, http://www.asp.net/web-pages/overview/getting-started/introducing-razor-syntax-c 2, Introduction ...
- Web开发中最致命的8个小错误
错误1:表单的label标签跟表单字段没有关联 利用“for”属性允许用户单击label也可以选中表单中的内容.这可以扩大复选框和单选框的点击区域,非常实用. 错误2:logo图片没有链接到主页 点击 ...
- java web 学习 --第十天(Java三级考试)
第九天学习内容:http://www.cnblogs.com/tobecrazy/p/3470195.html 需求概述 创建程序模块,读取并显示数据库中的书籍信息.当前有如下需求:需要显示数据库中所 ...
- web server && web framework角色区分
问题 web framework是否包括webserver? 是否可以包括? webserver 和 framework的关系是? https://www.quora.com/What-is-the- ...
- [译]如何在Web开发中使用Python
[译]如何在Web开发中使用Python 原文:HOWTO Use Python in the Web 摘要 这篇文档展示了Python如何融入到web中.它介绍了几种Python结合web服务器的方 ...
- Go Web:处理请求
处理请求 Request和Response http Requset和Response的内容包括以下几项: Request or response line Zero or more headers ...
- Go Web:Cookie
Cookie用来解决http协议无状态的问题. 首先,在服务端生成Cookie,然后在http响应header中设置Set-Cookie字段,客户端会读取到Set-Cookie字段后,会将cookie ...
- Mercedes offline programming/coding tips and guides
Mercedes offline programming/coding recommendations and guides: Offline coding: SCN or CVN coding wa ...
- Programming Languages: Application and Interpretation
http://cs.brown.edu/courses/cs173/2012/book/ 1 Introduction 1.1 Our Philosophy 1.2 The Structure of ...
随机推荐
- poj 2478 Farey Sequence(欧拉函数是基于寻求筛法素数)
http://poj.org/problem?id=2478 求欧拉函数的模板. 初涉欧拉函数,先学一学它主要的性质. 1.欧拉函数是求小于n且和n互质(包含1)的正整数的个数. 记为φ(n). 2. ...
- Maximal Square 我们都在寻找最高1子矩阵(leeCode)
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ret ...
- hdu1964之插头DP求最优值
Pipes Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...
- atitit..主流 浏览器 js 发动机 内核 市场份额 attialx总结vOa9
atitit..主流 浏览器 js 发动机 内核 市场份额 attialx总结vOa9 1. 浏览器内核 1 2. 浏览器的主要组件包含: 2 2.1. 主要组件体系结构 2 2.2. WebCor ...
- Ubuntu通过使用PyCharm 执行调试 Odoo 8.0 可能的问题
实现步骤,请移步http://shine-it.net/index.php?topic=16603.0 或 http://www.mindissoftware.com/2014/09/11/Run-O ...
- HDU 1069 Monkey and Banana(DP 长方体堆放问题)
Monkey and Banana Problem Description A group of researchers are designing an experiment to test the ...
- poj 3074 Sudoku(Dancing Links)
Sudoku Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8152 Accepted: 2862 Descriptio ...
- 注意事项: Solr设备 Hello World
试用 Solr-4.10.2 一 shards, 这两款机器 一是垃圾 rm -r example/solr/collection1/data/* 启动一个 node cd example java ...
- 再谈Hibernate级联删除——JPA下的Hibernate实现一对多级联删除CascadeType.DELETE_ORPHAN
声明: 1.本文系原创,非抄袭或转载过来的. 2.本文论点都亲手做过实验论证. 3.本文所讲的Hibernate配置都基于注解的方式,hbm语法未提供. 非常多人对持久层概念搞不清JPA.Hibern ...
- Android Studio 1.0 (稳定版) 完全攻略
这篇博文中主要从以下几点进行叙述: 1.Android Studio安装与使用 2.Android Studio特性 3.Android Studio优点 Android Studio 安装与使用 A ...