-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dishamodi0910:master' into master
- Loading branch information
Showing
38 changed files
with
24,730 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Bored API Example</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="wrapper"> | ||
<div class="banner-image"></div> | ||
<div class="content"> | ||
<h1>Bored Activity Generator</h1> | ||
<p>Explore random activities to beat boredom!</p> | ||
<div class="button-wrapper"> | ||
<button class="btn outline">Get Random Activity</button> | ||
</div> | ||
<div class="activity"><ul class="ul"> | ||
|
||
</ul></div> <!-- Added this line --> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const searchButton = document.querySelector('.btn'); | ||
const activityContainer = document.querySelector('.activity'); | ||
searchButton.addEventListener('click', getRandomActivity); | ||
|
||
function getRandomActivity() { | ||
const apiUrl = 'https://www.boredapi.com/api/activity'; | ||
|
||
// Make API request | ||
fetch(apiUrl) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
return response.json(); | ||
}) | ||
.then(data => { | ||
displayActivity(data.activity); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching activity:', error); | ||
}); | ||
} | ||
|
||
function displayActivity(activity) { | ||
let ul = document.querySelector(".ul") | ||
ul.innerHTML = ""; // Clear the ul | ||
let li = document.createElement("li"); | ||
li.innerText = activity; | ||
ul.appendChild(li); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
body { | ||
font-family: 'Lato', sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.container { | ||
background: linear-gradient(45deg, rgba(0,212,255,1) 0%, rgba(11,3,45,1) 100%); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
|
||
.wrapper { | ||
width: 80%; | ||
max-width: 600px; | ||
margin: auto; | ||
} | ||
|
||
|
||
|
||
.content { | ||
background-color: rgba(17, 25, 40, 0.25); | ||
padding: 20px; | ||
border-radius: 12px; | ||
text-align: center; | ||
color: #fff; | ||
} | ||
|
||
h1 { | ||
font-family: 'Righteous', sans-serif; | ||
text-transform: uppercase; | ||
font-size: 2.4rem; | ||
margin-bottom: 10px; | ||
} | ||
|
||
p { | ||
font-size: 1rem; | ||
line-height: 1.5; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.button-wrapper { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.btn { | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 24px; | ||
font-size: 0.8rem; | ||
letter-spacing: 1px; | ||
cursor: pointer; | ||
margin: 0 10px; | ||
} | ||
|
||
.outline { | ||
background: transparent; | ||
color: rgba(0, 212, 255, 0.9); | ||
border: 1px solid rgba(0, 212, 255, 0.6); | ||
transition: all .3s ease; | ||
} | ||
|
||
.outline:hover { | ||
transform: scale(1.05); | ||
} | ||
|
||
.fill { | ||
background: rgba(0, 212, 255, 0.9); | ||
color: rgba(255,255,255,0.95); | ||
font-weight: bold; | ||
transition: all .3s ease; | ||
} | ||
|
||
.fill:hover { | ||
transform: scale(1.05); | ||
} | ||
|
||
.activity { | ||
background-color: transparent; | ||
border-radius: 8px; | ||
margin-top: 20px; | ||
font-family: 'Lato', sans-serif; | ||
font-size: 1.2rem; | ||
line-height: 1.5; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
.ul li { | ||
margin-bottom: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Bored Activity Generator | ||
|
||
Explore random activities to beat boredom! This simple web app uses the Bored API to fetch random activities for users to try out. | ||
|
||
## Table of Contents | ||
|
||
- [Introduction](#introduction) | ||
- [Demo](#demo) | ||
- [Features](#features) | ||
- [Getting Started](#getting-started) | ||
- [Built With](#built-with) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
## Introduction | ||
|
||
This web application provides users with a quick and easy way to discover new activities to do when they're feeling bored. By clicking the "Get Random Activity" button, users can fetch a random activity suggestion from the Bored API and get inspired to try something new. | ||
|
||
## Demo | ||
|
||
Insert a GIF or a link to a live demo of the project here. | ||
|
||
## Features | ||
|
||
- Fetches random activities from the Bored API. | ||
- Simple and intuitive user interface. | ||
- Responsive design for seamless use on various devices. | ||
|
||
## Getting Started | ||
|
||
To get a local copy up and running follow these simple steps: | ||
|
||
## Getting Started | ||
|
||
- Clone the repository: | ||
```sh | ||
git clone https://github.com/SougataXdev/APIVerse.git | ||
``` | ||
- Open the project folder in your code editor. | ||
- Open the `index.html` file in your web browser to view the application locally. | ||
|
||
## Built With | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
- [Bored API](https://www.boredapi.com/) - For fetching random activity suggestions. | ||
|
||
## Contributing | ||
|
||
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. | ||
## Steps: | ||
1. Fork the Project | ||
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) | ||
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) | ||
4. Push to the Branch (`git push origin feature/AmazingFeature`) | ||
5. Open a Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
UNSPLASH_ACCESS="YOUR_ACCESS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.env |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Image Gallery</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<h1>Image Gallery</h1> | ||
|
||
<form id="searchForm"> | ||
<input type="text" id="keywordInput" placeholder="Enter keyword"> | ||
<button type="submit">Search</button> | ||
</form> | ||
|
||
<button id="randomImageButton"> | ||
Get Me a Random Image | ||
</button> | ||
|
||
<div id="imageContainer"></div> | ||
|
||
<script> | ||
document.getElementById('searchForm').addEventListener('submit', async function(event) { | ||
event.preventDefault(); | ||
const keyword = document.getElementById('keywordInput').value.trim(); | ||
if (keyword !== '') { | ||
const response = await fetch(`http://localhost:3000/images/keywordImage?query=${encodeURIComponent(keyword)}`); | ||
const images = await response.json(); | ||
displayImages(images); | ||
} | ||
}); | ||
|
||
document.getElementById('randomImageButton').addEventListener('click', async function() { | ||
const response = await fetch('http://localhost:3000/images/randomImage'); | ||
const images = await response.json(); | ||
displayImages(images); | ||
}); | ||
|
||
async function displayImages(images) { | ||
const imageContainer = document.getElementById('imageContainer'); | ||
imageContainer.innerHTML = ''; | ||
|
||
images.forEach(imageUrl => { | ||
const img = document.createElement('img'); | ||
img.src = imageUrl; | ||
img.alt = 'Image'; | ||
imageContainer.appendChild(img); | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const express = require('express'); | ||
const axios = require('axios'); | ||
const cors = require('cors'); | ||
const imageRouter = require('./routes/image') | ||
const app = express(); | ||
app.use(cors()); | ||
app.use(express.json()); | ||
app.use('/images', imageRouter); | ||
app.listen(3000, () => { | ||
console.log('Server is running on port 3000'); | ||
}); |
Oops, something went wrong.