티스토리 뷰

Web Tech/PHP

CGI 프로그래밍 예제

ned3y2k 2012. 2. 13. 03:31
윈도우 환경에서 사용 가능한 CGI 예제입니다.
posix 환경에서도 별 차이 없을것으로 예상됩니다만 iostream 이나 namespace 쓰는 부분에서 틀릴수 있습니다.
컴파일 프로그램은 Visual Studio입니다.

#include "stdafx.h"
#include <iostream>


int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Content-type: text/html" << std::endl <<std:: endl
<< "<html>" << std::endl
<< "<head>" << std::endl
<< "<title>CGI Test" << std::endl
<< "" << std::endl
<< "<body>" << std::endl
<< "<h1><em>" << std::endl
<< "Hello, World!" << std::endl
<< "</em></h1>" << std::endl
<< "</body>" << std::endl
<< "</html>";
return 0;
}

php 작업 하는데 뭐 이런게 필요하냐고 물어 보시는분 있겠지만 재미로 한번 해보시기 바랍니다!
posix 환경용(apache용) 코드는 파일 첨부로 게시합니다.
php cgi를 추가 하는 방식처럼 추가하면 됩니다.

2012. 4. 6 내용추가합니다.

GET, REQUEST등 각종 REQUEST를 처리하기 위해서는 an ANSI C library for CGI Programming 라이브러리가 추가로 필요합니다.

최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함