> For the complete documentation index, see [llms.txt](https://docs.punkland.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.punkland.io/punkland/punkland-studio/effective-punkland/http.md).

# HTTP 요청 보내기

Lua 스크립트를 이용해 아래와 같이 Http 요청을 보낼 수 있습니다.

## GET 요청 보내기

Server.HttpGet(url, callback)

예제)

{% code overflow="wrap" lineNumbers="true" %}

```lua
-- http://naver.com URL로 GET 요청 보내고, res로 데이터 받기
Server.HttpGet('http://naver.com', function(res)
  print(res) -- 웹페이지가 반환한 결과 텍스트가 출력됩니다.
end)
```

{% endcode %}

## POST 요청 보내기

Server.HttpPost(url, data, callback)\
\
예제)

{% code overflow="wrap" lineNumbers="true" %}

```lua
-- t 라는 테이블을 만들고, 보낼 POST 요청 데이터 넣기
t = {}
t.id = 1234
t.name = "Hello"

-- http://naver.com URL로 요청 보내고, res로 데이터 받기
Server.HttpGet('http://naver.com', t, function(res)
  print(res) -- 웹페이지가 반환한 결과 텍스트가 출력됩니다.
end)
```

{% endcode %}

## 웹 서버에서 데이터 받기

POST로 요청을 받을 경우, 아래와 같이 데이터를 출력할 수 있습니다.

이 데이터를 MySQL과 같은 데이터베이스에 넣어, 영구보관할 수 있습니다.

{% code overflow="wrap" lineNumbers="true" %}

```lua
<?php
echo $_POST["id"];
echo $_POST["name"];

echo "잘 받았습니다!";
?>
```

{% endcode %}

`Server.HttpGet` 에서 보낸 데이터가 웹 서버에 잘 도착하였는지를 확인하기 위한 코드입니다.

위 서버 스크립트 예재의 `print(res)` 에 의해 “1234Hello잘 받았습니다!” 가 출력됩니다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.punkland.io/punkland/punkland-studio/effective-punkland/http.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
