-
Notifications
You must be signed in to change notification settings - Fork 461
/
89 GET vs POST HTTP Methods.txt
106 lines (67 loc) · 2.62 KB
/
89 GET vs POST HTTP Methods.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
view.py
--------------------------------------------------------------------------------
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def home(request):
return render(request, 'home.html', {'name': 'Navin'})
def add(request):
val1 = int(request.POST['num1'])
val2 = int(request.POST['num2'])
res = val1 + val2
return render(request, "result.html", {'result': res})
--------------------------------------------------------------------------------
home.html
--------------------------------------------------------------------------------
{% extends 'base.html' %}
{% block content %}
<h1>Hello {{name}}!!!!!</h1>
<form action="add" method="POST">
{% csrf_token %}
Enter 1st number : <input type="text" name="num1"><br>
Enter 2st number : <input type="text" name="num2"><br>
<input type="submit">
</form>
{% endblock%}
--------------------------------------------------------------------------------
result.html
--------------------------------------------------------------------------------
{% extends 'base.html' %}
{% block content %}
Result : {{result}}
{% endblock%}
--------------------------------------------------------------------------------
base.html
--------------------------------------------------------------------------------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Telusko</title>
</head>
<body bgcolor="cyan">
{% block content %}
{% endblock %}
</body>
</html>
--------------------------------------------------------------------------------
urls.py ::calc
--------------------------------------------------------------------------------
from django.urls import include, path
from . import views
from django.contrib import admin
urlpatterns = [
path('', views.home, name='home'),
path('add', views.add, name='add')
]
--------------------------------------------------------------------------------
urls.py ::telusko
--------------------------------------------------------------------------------
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('calc.urls')),
path('admin/', admin.site.urls),
]