-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0815fe5
commit 6c52385
Showing
6 changed files
with
208 additions
and
0 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,16 @@ | ||
# Twitch API App | ||
|
||
This is a simple web application that displays live streams from Twitch using the Twitch API. | ||
|
||
## Setup | ||
|
||
1. Clone the repository. | ||
2. Navigate to the project directory. | ||
3. Install the dependencies: | ||
|
||
```bash | ||
npm install | ||
|
||
|
||
## Contributor | ||
### Revanth |
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,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Twitch API Viewer</title> | ||
</head> | ||
<body> | ||
<h1>Twitch API Viewer</h1> | ||
<div id="app"> | ||
<h2>Stream List</h2> | ||
<div id="streamList"></div> | ||
<h2>Deploy</h2> | ||
<input type="text" id="deployAppName" placeholder="App Name"> | ||
<input type="text" id="deploySourceUrl" placeholder="Source URL"> | ||
<button id="deployButton">Deploy</button> | ||
<h2>Scale</h2> | ||
<input type="text" id="scaleAppName" placeholder="App Name"> | ||
<input type="text" id="scaleDynoType" placeholder="Dyno Type"> | ||
<input type="number" id="scaleQuantity" placeholder="Quantity"> | ||
<button id="scaleButton">Scale</button> | ||
<h2>Logs</h2> | ||
<input type="text" id="logsAppName" placeholder="App Name"> | ||
<button id="logsButton">Get Logs</button> | ||
<ul id="results"></ul> | ||
</div> | ||
|
||
<script src="index.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,63 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
fetchTwitchStreams(); | ||
|
||
document.getElementById('deployButton').addEventListener('click', async () => { | ||
const appName = document.getElementById('deployAppName').value; | ||
const sourceUrl = document.getElementById('deploySourceUrl').value; | ||
const response = await fetch('/deploy', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ app_name: appName, source_url: sourceUrl }) | ||
}); | ||
const result = await response.json(); | ||
console.log(result); | ||
}); | ||
|
||
document.getElementById('scaleButton').addEventListener('click', async () => { | ||
const appName = document.getElementById('scaleAppName').value; | ||
const dynoType = document.getElementById('scaleDynoType').value; | ||
const quantity = document.getElementById('scaleQuantity').value; | ||
const response = await fetch('/scale', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ app_name: appName, dyno_type: dynoType, quantity: parseInt(quantity) }) | ||
}); | ||
const result = await response.json(); | ||
console.log(result); | ||
}); | ||
|
||
document.getElementById('logsButton').addEventListener('click', async () => { | ||
const appName = document.getElementById('logsAppName').value; | ||
const response = await fetch(`/logs?app_name=${appName}`); | ||
const result = await response.json(); | ||
const results = document.getElementById('results'); | ||
results.innerHTML = JSON.stringify(result, null, 2); | ||
}); | ||
}); | ||
|
||
async function fetchTitchStreams() { | ||
const clientId = 'YOUR_TWITCH_CLIENT_ID'; | ||
const endpoint = 'https://api.twitch.tv/helix/streams'; | ||
|
||
fetch(endpoint, { | ||
headers: { | ||
'Client-ID': clientId, | ||
'Authorization': 'Bearer YOUR_TWITCH_ACCESS_TOKEN' | ||
} | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
const streamList = document.getElementById('streamList'); | ||
data.data.forEach(stream => { | ||
const streamElement = document.createElement('div'); | ||
streamElement.className = 'stream'; | ||
streamElement.innerHTML = ` | ||
<h3>${stream.user_name}</h3> | ||
<p>${stream.title}</p> | ||
<img src="${stream.thumbnail_url}" alt="${stream.user_name}"> | ||
`; | ||
streamList.appendChild(streamElement); | ||
}); | ||
}) | ||
.catch(error => console.error('Error fetching streams:', error)); | ||
} |
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,16 @@ | ||
{ | ||
"name": "Twitch API App", | ||
"short_name": "TwitchApp", | ||
"start_url": ".", | ||
"display": "standalone", | ||
"background_color": "#000000", | ||
"theme_color": "#000000", | ||
"description": "An app to display Twitch streams.", | ||
"icons": [ | ||
{ | ||
"src": "icon.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
} | ||
] | ||
} |
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,14 @@ | ||
{ | ||
"name": "twitch-api-app", | ||
"version": "1.0.0", | ||
"description": "An app to display Twitch streams.", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "http-server ." | ||
}, | ||
"dependencies": { | ||
"http-server": "^0.12.3" | ||
}, | ||
"author": "Your Name", | ||
"license": "MIT" | ||
} |
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,68 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background: linear-gradient(135deg, #89fffd, #ef32d9); | ||
color: #fff; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
.container { | ||
text-align: center; | ||
padding: 20px; | ||
background: rgba(0, 0, 0, 0.5); | ||
border-radius: 10px; | ||
} | ||
|
||
h1 { | ||
font-size: 2.5em; | ||
margin-bottom: 20px; | ||
} | ||
|
||
#app { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.deployment { | ||
text-align: left; | ||
} | ||
|
||
.deployment h2 { | ||
margin-top: 20px; | ||
font-size: 1.5em; | ||
} | ||
|
||
.deployment p { | ||
margin: 5px 0; | ||
} | ||
|
||
.deployment button { | ||
background: #ef32d9; | ||
border: none; | ||
padding: 10px; | ||
color: #fff; | ||
cursor: pointer; | ||
border-radius: 5px; | ||
} | ||
|
||
.deployment button:hover { | ||
background: #a726c1; | ||
} | ||
|
||
.deployment input[type="number"] { | ||
width: 50px; | ||
padding: 5px; | ||
border-radius: 5px; | ||
border: none; | ||
} | ||
|
||
#streamList .stream { | ||
margin-bottom: 15px; | ||
} | ||
|
||
#streamList img { | ||
max-width: 100%; | ||
border-radius: 10px; | ||
} |