[TIL] HTTP REQUEST & RESPONSE


  • Http基礎知識
  • wwwという名前のクライアントからGet/postsをサーバに要求する
    Client: Http Request
    Server: Http Response
    *Http: Hyper Text Transfer Protocol
  • Web基本要素:Data、Logic、Layout
    Django: Model, View, Template
  • Django FrameWork Process
    Client -> Http Request -> django
    -> URLs -> View -> Http Response -> Client
  • -URLs
    urlpatterns = [
      path('admin/', admin site urls),
      path('posts/', views.index)
    ]
  • urlpatterns:djangoサーバで処理可能なurlリスト管理
  • path関数
  • クライアントは、posts/というURLでHttpリクエストを送信する.
    views.index(viewsモジュールのindex関数)はhttp要求
  • を処理する.
    def index(request):
       return HttpResponse('Hello HEEHAM~')
  • 要求クライアントから送信Http要求を含む情報
  • .
  • Http応答関数を使用してHttp応答を作成し、->ブラウザに戻って
  • を表示します.
  • Model
    ビューモデルによるデータの必要性(CRUD:Create、Read、Update、Delete:基本データ操作)
  • Template
    Html(django template)にデータをインポートし、
  • を使用します.