Add url tester

This commit is contained in:
ibratabian17
2024-10-22 17:55:26 +07:00
parent 53b24047e7
commit ad765b725f
4 changed files with 253 additions and 23 deletions

88
core/page/about.html Normal file
View File

@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenParty</title>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #1e1e1e;
color: #f5f5f5;
}
header {
background-color: #333;
padding: 20px;
text-align: center;
}
header h1 {
margin: 0;
color: #ff4081;
}
section {
padding: 20px;
}
section h2 {
color: #ff4081;
}
a {
color: #ff4081;
text-decoration: none;
}
footer {
background-color: #333;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
color: #888;
}
.cta {
display: block;
background-color: #ff4081;
padding: 10px 20px;
text-align: center;
border-radius: 5px;
color: #fff;
margin-top: 20px;
width: fit-content;
margin: 20px auto 0;
}
.cta:hover {
background-color: #ff5a94;
}
</style>
</head>
<body>
<header>
<h1>OpenParty</h1>
</header>
<section>
<h2>About</h2>
<p>OpenParty is a community-driven project developed by PartyTeam and LunarTeam as an alternative server solution for Just Dance Unlimited enthusiasts. This server allows you to enjoy the Just Dance Unlimited experience independently of official servers, which are no longer available.</p>
<p>This initiative aims to fill the void left by the discontinued official service, offering a reliable and enhanced alternative. OpenParty is crafted entirely from scratch, ensuring transparency and user trust. It strives to provide a seamless experience comparable to or even better than existing solutions like JDParty.</p>
<h2>Keep this project alive</h2>
<a href="https://www.patreon.com/ibratabian17" class="cta">Support on Patreon</a>
</section>
<footer>
&copy; 2024 OpenParty | Made by PartyTeam & ibratabian17
</footer>
</body>
</html>

128
core/page/test-request.html Normal file
View File

@@ -0,0 +1,128 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Test System</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #121212; /* Night mode background */
color: #e0e0e0; /* Light text on dark background */
}
label {
font-weight: bold;
}
.container {
max-width: 600px;
margin: auto;
padding: 20px;
background-color: #1f1f1f; /* Dark container background */
border: 1px solid #333;
border-radius: 10px;
}
input, textarea, select {
width: 100%;
margin: 10px 0;
padding: 10px;
background-color: #333;
color: #e0e0e0;
border: 1px solid #555;
border-radius: 5px;
}
button {
padding: 10px 20px;
background-color: #ff4081;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #ff4081;
}
pre {
background-color: #1f1f1f;
color: #e0e0e0;
padding: 10px;
border-radius: 5px;
white-space: pre-wrap;
word-wrap: break-word;
}
</style>
</head>
<body>
<div class="container">
<h2>URL Test System</h2>
<label for="url">Enter URL:</label>
<input type="text" id="url" placeholder="Enter URL">
<label for="method">Select Request Method:</label>
<select id="method">
<option value="GET">GET</option>
<option value="POST">POST</option>
<option value="PUT">PUT</option>
<option value="DELETE">DELETE</option>
</select>
<label for="headers">Enter Headers (JSON format):</label>
<textarea id="headers" rows="4" placeholder='{"Content-Type": "application/json"}'></textarea>
<label for="body">Enter Body (if POST/PUT) (JSON format):</label>
<textarea id="body" rows="4" placeholder='{"key": "value"}'></textarea>
<button onclick="sendRequest()">Send Request</button>
<h3>Output:</h3>
<pre id="output">Waiting for response...</pre>
</div>
<script>
async function sendRequest() {
const url = document.getElementById('url').value;
const method = document.getElementById('method').value;
const headersInput = document.getElementById('headers').value;
const bodyInput = document.getElementById('body').value;
const output = document.getElementById('output');
// Attempt to parse headers as JSON
let headers = {};
try {
headers = JSON.parse(headersInput);
} catch (e) {
output.textContent = 'Invalid headers. Make sure they are in JSON format.';
headers = {}
}
// Setup fetch options
const options = {
method: method,
headers: headers
};
// Add body for POST or PUT methods
if (method === 'POST' || method === 'PUT') {
try {
options.body = JSON.stringify(JSON.parse(bodyInput));
headers["Content-Type"] = "application/json"
} catch (e) {
options.body = bodyInput;
}
}
try {
const response = await fetch(url, options);
const responseText = await response.text();
// Display status and response
output.textContent = `Status: ${response.status}\n\nResponse:\n${responseText}`;
} catch (error) {
// Handle fetch error
output.textContent = `Error: ${error.message}`;
}
}
</script>
</body>
</html>

View File

@@ -3,6 +3,7 @@ console.log(`[DEFROUTE] Initializing....`)
var requestCountry = require("request-country");
const settings = require('../../settings.json');
var md5 = require('md5');
const fs = require('fs');
const core = {
main: require('../var').main,
generatePlaylist: require('../lib/playlist').generatePlaylist,
@@ -105,7 +106,7 @@ const resetTimeout = (ip, platform) => {
exports.initroute = (app, express, server) => {
app.get("/songdb/v1/songs", (req, res) => {
if (checkAuth(req, res)) {
returnSongdb(req.header('X-SkuId'), res);
returnSongdb(req.header('X-SkuId') || "jd2022-pc-ww", res);
}
});
@@ -226,44 +227,44 @@ exports.initroute = (app, express, server) => {
app.post("/carousel/v2/pages/:mode", (req, res) => {
var search = ""
if (req.body.searchString && req.body.searchString != "") {
search = req.body.searchString
search = req.body.searchString
} else if (req.body.searchTags && req.body.searchTags != undefined) {
search = req.body.searchTags[0]
search = req.body.searchTags[0]
} else {
search = ""
search = ""
}
let action = null
let isPlaylist = false
switch (req.params.mode) {
case "party":
case "partycoop":
action = "partyMap"
break
case "party":
case "partycoop":
action = "partyMap"
break
case "sweat":
action = "sweatMap"
break
case "sweat":
action = "sweatMap"
break
case "create-challenge":
action = "create-challenge"
break
case "create-challenge":
action = "create-challenge"
break
case "jd2019-playlists":
case "jd2020-playlists":
case "jd2021-playlists":
case "jd2022-playlists":
isPlaylist = true
break
case "jd2019-playlists":
case "jd2020-playlists":
case "jd2021-playlists":
case "jd2022-playlists":
isPlaylist = true
break
}
if (isPlaylist) return res.json(core.generatePlaylist().playlistcategory)
if (action != null)
return res.send(core.CloneObject(core.generateCarousel(search, action)))
return res.send(core.CloneObject(core.generateCarousel(search, action)))
else return res.json({})
});
});
app.get("/profile/v2/country", function (request, response) {
var country = requestCountry(request);
@@ -392,4 +393,17 @@ exports.initroute = (app, express, server) => {
});
});
app.get('/openparty/server/:page', function (req, res) {
const filePath = path.join(__dirname, '../page/', req.params.page);
// Check if the file exists before trying to send it
if (fs.existsSync(filePath)) {
res.sendFile(filePath);
} else {
res.status(404).send('Not Found');
}
});
};

View File

@@ -1,6 +1,6 @@
{
"name": "open-party",
"version": "1.0.0",
"version": "1.1.0",
"description": "Ibratabian17's JDU Code",
"main": "server.js",
"scripts": {