easy cgi
1.0.0
npm install -g easy-cgi
CGI 실행 파일을 사용하는 앱의 디렉토리를 만듭니다.
앱 디렉토리
app
└---hello.sh
앱/hello.sh
#! /bin/sh
# Headers are written first. The special "Status"
# header indicates the response status code
echo " Status: 200 "
echo " Content-Type: text/plain "
echo
# Followed by a response body
echo " Hello World! "파일에 대한 권한을 실행하십시오
chmod +x hello.sh그런 다음 CGI 서버를 시작하십시오
cgi주소에 액세스하십시오 http : // localhost : 8080/Hello는 브라우저에서
경로는 파일 이름으로 자동으로 생성됩니다
예:
app/hello.sh 파일의 경우 경로는 /hello 입니다app/foo/bar.sh 파일의 경우 경로는 /foo/bar 입니다app/index.sh 파일의 경우 경로는 / 입니다.app/foo/index.sh 파일의 경우 경로는 /foo 입니다
app/src디렉토리를 작성하면 무시됩니다.
동적 경로는 파일 이름 또는 디렉토리로 밑줄을 추가하여 생성됩니다.
예:
app/users/_id.sh 파일의 경우 경로는 /users/<id> 입니다app/_foo/bar.sh 파일의 경우 경로는 /<foo>/bar 입니다JSON 형식의 요청 환경 변수를 통해 요청 값에 액세스 할 수 있습니다.
요청 환경 변수는 모양입니다
{
"body" : {},
"params" : {},
"query" : {},
"headers" : {},
"files" : {}
}아직 세션이 지원되지 않습니다
정적 파일을 제공하려면 static 디렉토리를 만듭니다