-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb2fcee
commit 8f33027
Showing
20 changed files
with
555 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
url <- "https://korcen.shibadogs.net/api/v1/korcen" | ||
json_data <- '{"input": "욕설이 포함될수 있는 메시지", | ||
"replace_front": "감지된 욕설 앞부분에 넣을 메시지 (옵션)", | ||
"replace_end": "감지된 욕설 뒷부분에 넣을 메시지 (옵션)"}' | ||
|
||
headers <- c("Accept: application/json", "Content-Type: application/json") | ||
con <- url(url, "rb") | ||
write(json_data, con) | ||
response <- readLines(con, warn=FALSE) | ||
close(con) | ||
|
||
cat("Response:", response, "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main() { | ||
const char *json_data = | ||
"{" | ||
"\"input\":\"욕설이 포함될수 있는 메시지\"," | ||
"\"replace_front\":\"감지된 욕설 앞부분에 넣을 메시지 (옵션)\"," | ||
"\"replace_end\":\"감지된 욕설 뒷부분에 넣을 메시지 (옵션)\"" | ||
"}"; | ||
|
||
char command[1024]; | ||
snprintf(command, sizeof(command), | ||
"echo '%s' | curl -X POST -H \"Accept: application/json\" -H \"Content-Type: application/json\" -d @- \"https://korcen.shibadogs.net/api/v1/korcen\"", | ||
json_data); | ||
|
||
system(command); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <iostream> | ||
#include <cstdlib> | ||
|
||
int main() { | ||
std::string json_data = | ||
"{" | ||
"\"input\": \"욕설이 포함될수 있는 메시지\"," | ||
"\"replace_front\": \"감지된 욕설 앞부분에 넣을 메시지 (옵션)\"," | ||
"\"replace_end\": \"감지된 욕설 뒷부분에 넣을 메시지 (옵션)\"" | ||
"}"; | ||
|
||
std::string command = "echo \"" + json_data + "\" | curl -X POST -H \"Accept: application/json\" -H \"Content-Type: application/json\" -d @- \"https://korcen.shibadogs.net/api/v1/korcen\""; | ||
|
||
system(command.c_str()); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-module(example). | ||
-export([call_api/0]). | ||
|
||
call_api() -> | ||
URL = "https://korcen.shibadogs.net/api/v1/korcen", | ||
Headers = [ | ||
{"Accept", "application/json"}, | ||
{"Content-Type", "application/json"} | ||
], | ||
Body = "{" | ||
"\"input\":\"욕설이 포함될수 있는 메시지\"," | ||
"\"replace_front\":\"감지된 욕설 앞부분에 넣을 메시지 (옵션)\"," | ||
"\"replace_end\":\"감지된 욕설 뒷부분에 넣을 메시지 (옵션)\"" | ||
"}", | ||
|
||
case httpc:request(post, {URL, Headers, "application/json", Body}, [], []) of | ||
{ok, {{_, 200, _}, _, ResponseBody}} -> | ||
io:format("Response: ~s~n", [ResponseBody]); | ||
{ok, {{_, StatusCode, _}, _, _}} -> | ||
io:format("Error: HTTP ~p~n", [StatusCode]); | ||
{error, Reason} -> | ||
io:format("Request failed: ~p~n", [Reason]) | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# mix.exs | ||
# | ||
# defp deps do | ||
# [ | ||
# {:httpoison, "~> 1.8"}, | ||
# {:jason, "~> 1.4"} | ||
# ] | ||
#end | ||
|
||
defmodule KorcenClient do | ||
@url "https://korcen.shibadogs.net/api/v1/korcen" | ||
@headers [ | ||
{"Accept", "application/json"}, | ||
{"Content-Type", "application/json"} | ||
] | ||
|
||
def call_api do | ||
body = %{ | ||
"input" => "욕설이 포함될수 있는 메시지", | ||
"replace_front" => "감지된 욕설 앞부분에 넣을 메시지 (옵션)", | ||
"repace_end" => "감지된 욕설 뒷부분에 넣을 메시지 (옵션)" | ||
} | ||
|> Jason.endcode!() | ||
|
||
case HTTPoison.post(@url, body, @headers) do | ||
{:ok, %HTTPoison.Response{status_code: 200, body: response_body}} -> | ||
IO.puts("Response: #{response_body}") | ||
|
||
{:ok, %HTTPoison.Response{status_code: status_code}} -> | ||
IO.puts("Error: Received HTTP status #{status_code}") | ||
|
||
{:error, HTTPoison.Response{reason: reason}} -> | ||
IO.puts("HTTP Request failed: #{inspect(reason)}") | ||
end | ||
end | ||
end | ||
|
||
KorcenClient.call_api() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
program korcen_api | ||
use iso_fortran_env, only: output_unit | ||
implicit none | ||
character(len=1024) :: json_data, response | ||
integer :: status | ||
|
||
json_data = '{' // & | ||
'"input": "욕설이 포함될수 있는 메시지",' // & | ||
'"replace_front": "감지된 욕설 앞부분에 넣을 메시지 (옵션)",' // & | ||
'"replace_end": "감지된 욕설 뒷부분에 넣을 메시지 (옵션)"' // & | ||
'}' | ||
|
||
call execute_command_line('curl -s -X POST ' // & | ||
'-H "Accept: application/json" ' // & | ||
'-H "Content-Type: application/json" ' // & | ||
'-d ''' // trim(json_data) // ''' ' // & | ||
'"https://korcen.shibadogs.net/api/v1/korcen" > response.json', status) | ||
|
||
open(unit=10, file="response.json", status="old", action="read", iostat=status) | ||
if (status == 0) then | ||
read(10, '(A)') response | ||
print *, "Response:", trim(response) | ||
close(10) | ||
else | ||
print *, "Error: Failed to read response." | ||
end if | ||
end program korcen_api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Network.HTTP | ||
import Network.URI | ||
|
||
main :: IO () | ||
main = do | ||
let url = "https://korcen.shibadogs.net/api/v1/korcen" | ||
let jsonData = "{\"input\": \"욕설이 포함될수 있는 메시지\", \"replace_front\": \"감지된 욕설 앞부분에 넣을 메시지 (옵션)\", \"replace_end\": \"감지된 욕설 뒷부분에 넣을 메시지 (옵션)\"}" | ||
case parseURI url of | ||
Nothing -> putStrLn "Invalid URL" | ||
Just uri -> do | ||
let req = Request { | ||
rqURI = uri, | ||
rqMethod = POST, | ||
rqHeaders = [mkHeader HdrContentType "application/json"], | ||
rqBody = jsonData | ||
} | ||
response <- simpleHTTP req >>= getResponseBody | ||
putStrLn ("Response: " ++ response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import java.io.*; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
public class example { | ||
public static void main(String[] args) { | ||
try { | ||
URL url = new URL("https://korcen.shibadogs.net/api/v1/korcen"); | ||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||
connection.setRequestMethod("POST"); | ||
connection.setRequestProperty("Accept", "application/json"); | ||
connection.setRequestProperty("Content-Type", "application/json"); | ||
connection.setDoOutput(true); | ||
|
||
String jsonInput = "{" | ||
+ "\"input\":\"욕설이 포함될수 있는 메시지\"," | ||
+ "\"replace_front\":\"감지된 욕설 앞부분에 넣을 메시지 (옵션)\"," | ||
+ "\"replace_end\":\"감지된 욕설 뒷부분에 넣을 메시지 (옵션)\"" | ||
+ "}"; | ||
|
||
try (OutputStream outputStream = connection.getOutputStream(); | ||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"))) { | ||
writer.write(jsonInput); | ||
writer.flush(); | ||
} | ||
|
||
int responseCode = connection.getResponseCode(); | ||
System.out.println("Response Code: " + responseCode); | ||
|
||
if (responseCode == HttpURLConnection.HTTP_OK) { | ||
try (BufferedReader inputStream = new BufferedReader(new InputStreamReader(connection.getInputStream())); | ||
StringWriter response = new StringWriter()) { | ||
String inputLine; | ||
while ((inputLine = inputStream.readLine()) != null) { | ||
response.write(inputLine); | ||
} | ||
System.out.println("Response: " + response.toString()); | ||
} | ||
} else { | ||
System.out.println("Error: " + responseCode); | ||
} | ||
|
||
connection.disconnect(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Sockets | ||
|
||
function call_api() | ||
url = "https://korcen.shibadogs.net/api/v1/korcen" | ||
json_data = """ | ||
{ | ||
"input": "욕설이 포함될수 있는 메시지", | ||
"replace_front": "감지된 욕설 앞부분에 넣을 메시지 (옵션)", | ||
"replace_end": "감지된 욕설 뒷부분에 넣을 메시지 (옵션)" | ||
} | ||
""" | ||
|
||
host, port = split(url[9:end], "/")[1], 443 | ||
socket = connect(host, port) | ||
|
||
request = """ | ||
POST /api/v1/korcen HTTP/1.1 | ||
Host: korcen.shibadogs.net | ||
Accept: application/json | ||
Content-Type: application/json | ||
Content-Length: $(length(json_data)) | ||
$(json_data) | ||
""" | ||
|
||
write(socket, request) | ||
response = read(socket, String) | ||
close(socket) | ||
|
||
println("Response: ", response) | ||
end | ||
|
||
call_api() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
local json_data = [[ | ||
{ | ||
"input": "욕설이 포함될수 있는 메시지", | ||
"replace_front": "감지된 욕설 앞부분에 넣을 메시지 (옵션)", | ||
"replace_end": "감지된 욕설 뒷부분에 넣을 메시지 (옵션)" | ||
} | ||
]] | ||
|
||
local command = "curl -s -X POST " .. | ||
"-H \"Accept: application/json\" " | ||
"-H \"Content-Type: application/json\" " | ||
"-d '" .. json_data:gsub("'", "\\'") .. "' " .. | ||
"\"https://korcen.shibadogs.net/api/v1/korcen\"" | ||
|
||
local handle = io.popen(command) | ||
local response = handle:read("*a") | ||
handle:close() | ||
|
||
print("Response: " .. response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
program KorcenAPI; | ||
uses fphttpclient, fpjson, jsonparser; | ||
|
||
var | ||
Client: TFPHTTPClient; | ||
Response: String; | ||
JsonData: String; | ||
begin | ||
JsonData := '{' + | ||
'"input": "욕설이 포함될수 있는 메시지",' + | ||
'"replace_front": "감지된 욕설 앞부분에 넣을 메시지 (옵션)",' + | ||
'"replace_end": "감지된 욕설 뒷부분에 넣을 메시지 (옵션)"' + | ||
'}'; | ||
|
||
Client := TFPHTTPClient.Create(nil); | ||
try | ||
Client.AddHeader('Content-Type', 'application/json'); | ||
Client.AddHeader('Accept', 'application/json'); | ||
Response := Client.SimplePost('https://korcen.shibadogs.net/api/v1/korcen', JsonData); | ||
Writeln('Response: ', Response); | ||
except | ||
on E: Exception do | ||
Writeln('Error: ', E.Message); | ||
end; | ||
Client.Free; | ||
end. |
Oops, something went wrong.