Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions django_project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def home(request):
data2 = reponse2.json()
result2 = data2["message"]


# USING APIS => Example 3
response3 = requests.get('https://api.chucknorris.io/jokes/random')
data3 = response3.json()
result3 = data3["value"]

return render(request, 'templates/index.html', {'result': result, 'result2': result2})
35 changes: 30 additions & 5 deletions static/styles.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
body{
background: hotpink
background: pink;
font-family: 'Ariel', sans-serif;
}

img{
width: 100px;
.container{
width: 80%;
margin: auto;
padding: 20px;
}
h1, h2{
text-align: center;
color: white;
}
.random-pet, .chuck-joke {
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
}
.image-random img {
width: 150px;
height: 100px;
border-radius: 9999;
border-radius: 75px;
display: block;
margin: 0 auto;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.joke-content {
font-style: italic;
color: #555;
text-align: center;
}
24 changes: 20 additions & 4 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,29 @@
<title>Document</title>
</head>
<body>
<div class="container">
<h1>Hello, My name is Evans </h1>

{{result}}

<h1>Random Pet</h1>
{{result2}}
</div>

<div class="random pet">
<h2>Random Pet</h2>
{{result2}}
<div class="imagerandom">
<img src={{result2}} alt="random pet" />
</div>
</div>


<div class="chuck joke">
<h2>Chuck Norris</h2>
<div class="joke_content">
{{result3}}
</div>
</div>




</body>
</html>