import java.io.*;
public class lang {
public static void main(String[] args) {
try {
doFunction();
}
catch ( Exception e ) {
}
}
public static void doFunction() throws IOException {
String strMethod = System.getenv("REQUEST_METHOD");
System.out.println( "Content-Type: text/html; Charset=shift_jis" );
System.out.println( "" );
System.out.println( strMethod + "<br>" );
if ( strMethod.equals( "GET" ) ) {
String strQueryString =
System.getenv( "QUERY_STRING" );
System.out.println( strQueryString );
}
if ( strMethod.equals( "POST" ) ) {
BufferedReader read =
new BufferedReader(new InputStreamReader(System.in));
String line = null;
while( (line = read.readLine()) != null ) {
System.out.println( line );
}
}
}
}
WSH ( VBScript )
AN HTTP Server で、.vbs を cscript.exe //Nologo で登録
' オブジェクト作成
Set WshShell = CreateObject("WScript.Shell")
' 環境変数を取得
Set WshSysEnv = WshShell.Environment("PROCESS")
strMethod = UCase( WshSysEnv("REQUEST_METHOD") )
WScript.Echo "Content-Type: text/html; Charset=shift_jis"
WScript.Echo ""
WScript.Echo strMethod & "<br>"
if strMethod = "GET" then
strQueryString = WshSysEnv("QUERY_STRING")
WScript.Echo strQueryString
end if
if strMethod = "POST" then
WScript.Echo Wscript.StdIn.ReadAll
end if
VB + Framework
Imports System.Environment
Imports System.IO
Module MyModule
' ********************************************************' * 実行' ********************************************************
Sub Main()
' PATH 環境変数取得
Dim strMethod as String = GetEnvironmentVariable( "REQUEST_METHOD" )
Console.WriteLine("Content-Type: text/html; Charset=shift_jis")
Console.WriteLine("")
Console.WriteLine("{0}<br>", strMethod )
if strMethod = "GET" then
Dim strQueryString as String = GetEnvironmentVariable( "QUERY_STRING" )
Console.WriteLine(strQueryString)
end if
if strMethod = "POST" then
Dim line As String
line = Console.ReadLine()
Do While Not line Is Nothing
Console.WriteLine(line)
line = Console.ReadLine()
Loop
end if
End Sub
End Module
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace WebApp1
{
class Program
{
static void Main(string[] args)
{
//string formtype = "GET";
string formtype = "POST";
string[] param = {""};
// ******************************// Console.WriteLine を UTF8 で// ******************************
Console.OutputEncoding = Encoding.UTF8;
// ******************************// メソッド// ******************************
string method = Environment.GetEnvironmentVariable("REQUEST_METHOD");
// ******************************// QUERY_STRING// ******************************
string query_string = System.Environment.GetEnvironmentVariable("QUERY_STRING");
// ******************************// HTTP ヘッダ// PHP の session_cache_limiter// ******************************
Console.WriteLine("Content-Type: text/html; charset=utf-8");
Console.WriteLine("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
Console.WriteLine("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
Console.WriteLine("Pragma: no-cache");
Console.WriteLine();
string message = "<div>こんにちは世界</div>";
// ******************************// HTML// ******************************
string html = @"<!DOCTYPE html>
<html>
<head>
</head>
<body>
#{message}
<form method='#{formtype}'>
<p>氏名 : <input type='text' name='field1' value='#{field1}'></p>
<p>フリガナ : <input type='text' name='field2' value='#{field2}'></p>
<p>送信 : <input type='submit' name='send' value='送信'></p>
</form>
</body>
</html>";
html = html.Replace("#{formtype}", formtype);
// ******************************// GET// ******************************
if (method == "GET")
{
param = query_string.Split('&');
}
// ******************************// POST// ******************************
if (method == "POST")
{
string line = null;
line = Console.ReadLine();
param = line.Split('&');
}
foreach (string set in param)
{
string[] key_value = set.Split('=');
if (key_value[0] == "field1")
{
// System.Web を参照して using System.Web;
key_value[1] = HttpUtility.UrlDecode(key_value[1]);
html = html.Replace("#{field1}", key_value[1]);
}
if (key_value[0] == "field2")
{
key_value[1] = HttpUtility.UrlDecode(key_value[1]);
html = html.Replace("#{field2}", key_value[1]);
}
}
html = html.Replace("#{field1}", "");
html = html.Replace("#{field2}", "");
// #{} は Ruby の真似
html = html.Replace("#{message}", message);
Console.WriteLine(html);
}
}
}
Jscript + Framework
import System;
import System.IO;
// PATH 環境変数取得
var strMethod : String =
Environment.GetEnvironmentVariable( "REQUEST_METHOD" );
// HTTP ヘッダ
Console.WriteLine("Content-Type: text/html; Charset=shift_jis");
Console.WriteLine("");
Console.WriteLine("{0}<br>", strMethod );
if ( strMethod == "GET" ) {
var strQueryString : String =
Environment.GetEnvironmentVariable( "QUERY_STRING" );
Console.WriteLine(strQueryString);
}
if ( strMethod == "POST" ) {
var line : String = null;
line = Console.ReadLine();
while( line != null ) {
Console.WriteLine(line);
line = Console.ReadLine();
}
}
WSH ( Jscript )
AN HTTP Server で、.js を cscript.exe //Nologo で登録
// オブジェクト作成
var WshShell = new ActiveXObject("WScript.Shell");
// システム環境変数を取得
var WshSysEnv = WshShell.Environment("PROCESS");
var strMethod = WshSysEnv("REQUEST_METHOD");
WScript.Echo( "Content-Type: text/html; Charset=shift_jis" );
WScript.Echo( "" );
WScript.Echo( strMethod + "<br>" )
if ( strMethod == "GET" ) {
strQueryString = WshSysEnv("QUERY_STRING");
WScript.Echo( strQueryString );
}
if ( strMethod == "POST" ) {
WScript.Echo( WScript.StdIn.ReadAll() );
}