상세 컨텐츠

본문 제목

http 프로토콜 (15~16강)

django

by 개복신 개발자 2021. 7. 19. 21:32

본문

728x90
반응형

http 프로토콜: 통신 규약

--컴퓨터끼리 통신을 할 때의 약속

 

get방식 & post 방식-->서버에 요청

 

get 방식

서버로부터 정보를 조회하기 위해서 설계

쿼리 스트링을 통해 전송

(쿼리 스트링= http://hostname[:port]/folder/file?param1=value1&param2=value2&param3=value3 등의 형식을 가짐)

 

post 방식

서버내의 정보를 만들거나 수정할 때 사용

body을 이용해 전송-body안에 데이터를 넣어서 전송


<form action="/account/hello_world/" method="POST"> 
            <!-- action에는 적용시킬 url을 작성 -->
            {% csrf_token %}
            <input type="submit" class="btn btn-primary " value="POST">

</form>

- action="/account/hello_world/"

action에 적힌 url대로 해당 내용이 작동됨

hello_world 함수를 작동시킴

 

def hello_world(request):
	if request.method == "POST":
        return render(request, 'accountapp/hello_world.html', context={'text': 'POST METHOD!'})
    else:
        return render(request, 'accountapp/hello_world.html', context={'text': 'GET METHOD!'})

request.method --> 프로토콜 방식

 

반응형

'django' 카테고리의 다른 글

DB 정보 접근 및 장고 템플릿 내 for loop  (0) 2021.07.22
텍스트 작성 내용 보이기 (17강)  (0) 2021.07.19
models.py class 작성 (14강)  (0) 2021.07.15
static 설정(11강)  (0) 2021.07.15
부트스트랩 적용 (10강)  (0) 2021.07.15

관련글 더보기

댓글 영역