Add 2 files
Browse files- README.md +7 -5
- index.html +418 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: test
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,418 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Medieval Pong: Siege of the Castle</title>
|
| 7 |
+
<style>
|
| 8 |
+
@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&display=swap');
|
| 9 |
+
|
| 10 |
+
body {
|
| 11 |
+
margin: 0;
|
| 12 |
+
padding: 0;
|
| 13 |
+
background-color: #111;
|
| 14 |
+
overflow: hidden;
|
| 15 |
+
font-family: 'MedievalSharp', cursive;
|
| 16 |
+
color: #d4af37;
|
| 17 |
+
text-align: center;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
#game-container {
|
| 21 |
+
position: relative;
|
| 22 |
+
width: 800px;
|
| 23 |
+
height: 500px;
|
| 24 |
+
margin: 20px auto;
|
| 25 |
+
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="800" height="500" viewBox="0 0 800 500"><rect width="800" height="500" fill="%23101010"/><rect x="50" y="100" width="700" height="300" fill="%23222" stroke="%23d4af37" stroke-width="2"/><rect x="300" y="150" width="200" height="200" fill="%23333" stroke="%23d4af37" stroke-width="2"/><rect x="350" y="200" width="100" height="150" fill="%23555" stroke="%23d4af37" stroke-width="2"/><rect x="375" y="200" width="50" height="30" fill="%23d4af37"/><polygon points="400,50 450,150 350,150" fill="%23777" stroke="%23d4af37" stroke-width="2"/><circle cx="400" cy="250" r="10" fill="%23d4af37"/><line x1="400" y1="260" x2="400" y2="350" stroke="%23d4af37" stroke-width="2"/><line x1="370" y1="290" x2="430" y2="290" stroke="%23d4af37" stroke-width="2"/></svg>');
|
| 26 |
+
border: 3px solid #d4af37;
|
| 27 |
+
box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
#scoreboard {
|
| 31 |
+
display: flex;
|
| 32 |
+
justify-content: space-between;
|
| 33 |
+
padding: 10px 50px;
|
| 34 |
+
font-size: 24px;
|
| 35 |
+
text-shadow: 2px 2px 4px #000;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.paddle {
|
| 39 |
+
position: absolute;
|
| 40 |
+
width: 20px;
|
| 41 |
+
height: 100px;
|
| 42 |
+
background: linear-gradient(to bottom, #8B0000, #B22222, #8B0000);
|
| 43 |
+
border: 2px solid #d4af37;
|
| 44 |
+
border-radius: 5px;
|
| 45 |
+
box-shadow: 0 0 15px #FF4500;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
#left-paddle {
|
| 49 |
+
left: 30px;
|
| 50 |
+
top: 200px;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
#right-paddle {
|
| 54 |
+
right: 30px;
|
| 55 |
+
top: 200px;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.flame {
|
| 59 |
+
position: absolute;
|
| 60 |
+
width: 10px;
|
| 61 |
+
height: 20px;
|
| 62 |
+
background: radial-gradient(ellipse at center, #FF8C00 0%, #FF4500 50%, transparent 70%);
|
| 63 |
+
border-radius: 50%;
|
| 64 |
+
animation: flicker 0.3s infinite alternate;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
@keyframes flicker {
|
| 68 |
+
0% { opacity: 0.7; transform: scaleY(0.9); }
|
| 69 |
+
100% { opacity: 1; transform: scaleY(1.1); }
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
#ball {
|
| 73 |
+
position: absolute;
|
| 74 |
+
width: 20px;
|
| 75 |
+
height: 20px;
|
| 76 |
+
background: radial-gradient(circle at 30% 30%, #FFF, #FFD700, #B22222);
|
| 77 |
+
border-radius: 50%;
|
| 78 |
+
box-shadow: 0 0 10px #FF4500;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
.explosion {
|
| 82 |
+
position: absolute;
|
| 83 |
+
width: 40px;
|
| 84 |
+
height: 40px;
|
| 85 |
+
border-radius: 50%;
|
| 86 |
+
background: radial-gradient(circle, rgba(255,69,0,0.8) 0%, rgba(255,140,0,0.6) 40%, rgba(255,215,0,0) 70%);
|
| 87 |
+
animation: explode 0.5s forwards;
|
| 88 |
+
pointer-events: none;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
@keyframes explode {
|
| 92 |
+
0% { transform: scale(0.1); opacity: 1; }
|
| 93 |
+
100% { transform: scale(2); opacity: 0; }
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.particle {
|
| 97 |
+
position: absolute;
|
| 98 |
+
width: 6px;
|
| 99 |
+
height: 6px;
|
| 100 |
+
background-color: #FF8C00;
|
| 101 |
+
border-radius: 50%;
|
| 102 |
+
animation: particle-fly 1s forwards;
|
| 103 |
+
pointer-events: none;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
@keyframes particle-fly {
|
| 107 |
+
0% { transform: translate(0, 0); opacity: 1; }
|
| 108 |
+
100% { transform: translate(var(--tx), var(--ty)); opacity: 0; }
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
#start-screen, #game-over {
|
| 112 |
+
position: absolute;
|
| 113 |
+
top: 0;
|
| 114 |
+
left: 0;
|
| 115 |
+
width: 100%;
|
| 116 |
+
height: 100%;
|
| 117 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 118 |
+
display: flex;
|
| 119 |
+
flex-direction: column;
|
| 120 |
+
justify-content: center;
|
| 121 |
+
align-items: center;
|
| 122 |
+
z-index: 10;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
#game-over {
|
| 126 |
+
display: none;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
h1 {
|
| 130 |
+
font-size: 48px;
|
| 131 |
+
margin-bottom: 20px;
|
| 132 |
+
text-shadow: 3px 3px 5px #000;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
button {
|
| 136 |
+
padding: 15px 30px;
|
| 137 |
+
font-family: 'MedievalSharp', cursive;
|
| 138 |
+
font-size: 20px;
|
| 139 |
+
background: linear-gradient(to bottom, #8B0000, #B22222);
|
| 140 |
+
color: #d4af37;
|
| 141 |
+
border: 2px solid #d4af37;
|
| 142 |
+
border-radius: 5px;
|
| 143 |
+
cursor: pointer;
|
| 144 |
+
transition: all 0.3s;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
button:hover {
|
| 148 |
+
transform: scale(1.05);
|
| 149 |
+
box-shadow: 0 0 15px #FF4500;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
#instructions {
|
| 153 |
+
margin-top: 20px;
|
| 154 |
+
font-size: 18px;
|
| 155 |
+
}
|
| 156 |
+
</style>
|
| 157 |
+
</head>
|
| 158 |
+
<body>
|
| 159 |
+
<div id="game-container">
|
| 160 |
+
<div id="scoreboard">
|
| 161 |
+
<div id="player-score">Player: 0</div>
|
| 162 |
+
<div id="ai-score">AI: 0</div>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
<div id="left-paddle" class="paddle"></div>
|
| 166 |
+
<div id="right-paddle" class="paddle"></div>
|
| 167 |
+
<div id="ball"></div>
|
| 168 |
+
|
| 169 |
+
<div id="start-screen">
|
| 170 |
+
<h1>Medieval Pong: Siege of the Castle</h1>
|
| 171 |
+
<button id="start-button">Begin the Siege!</button>
|
| 172 |
+
<div id="instructions">
|
| 173 |
+
Defend your castle! Use W/S keys to move your flaming paddle.<br>
|
| 174 |
+
Each hit creates an explosive impact. First to 5 wins!
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
|
| 178 |
+
<div id="game-over">
|
| 179 |
+
<h1 id="result-message">Victory!</h1>
|
| 180 |
+
<button id="restart-button">Fight Again!</button>
|
| 181 |
+
</div>
|
| 182 |
+
</div>
|
| 183 |
+
|
| 184 |
+
<script>
|
| 185 |
+
// Game elements
|
| 186 |
+
const gameContainer = document.getElementById('game-container');
|
| 187 |
+
const leftPaddle = document.getElementById('left-paddle');
|
| 188 |
+
const rightPaddle = document.getElementById('right-paddle');
|
| 189 |
+
const ball = document.getElementById('ball');
|
| 190 |
+
const playerScoreDisplay = document.getElementById('player-score');
|
| 191 |
+
const aiScoreDisplay = document.getElementById('ai-score');
|
| 192 |
+
const startScreen = document.getElementById('start-screen');
|
| 193 |
+
const gameOverScreen = document.getElementById('game-over');
|
| 194 |
+
const resultMessage = document.getElementById('result-message');
|
| 195 |
+
const startButton = document.getElementById('start-button');
|
| 196 |
+
const restartButton = document.getElementById('restart-button');
|
| 197 |
+
|
| 198 |
+
// Game state
|
| 199 |
+
let gameRunning = false;
|
| 200 |
+
let playerScore = 0;
|
| 201 |
+
let aiScore = 0;
|
| 202 |
+
let ballX = 400;
|
| 203 |
+
let ballY = 250;
|
| 204 |
+
let ballSpeedX = 4;
|
| 205 |
+
let ballSpeedY = 4;
|
| 206 |
+
let leftPaddleY = 200;
|
| 207 |
+
let rightPaddleY = 200;
|
| 208 |
+
const paddleHeight = 100;
|
| 209 |
+
const paddleWidth = 20;
|
| 210 |
+
const ballSize = 20;
|
| 211 |
+
const gameWidth = 800;
|
| 212 |
+
const gameHeight = 500;
|
| 213 |
+
|
| 214 |
+
// Key states
|
| 215 |
+
const keys = {
|
| 216 |
+
w: false,
|
| 217 |
+
s: false
|
| 218 |
+
};
|
| 219 |
+
|
| 220 |
+
// Add flame effects to paddles
|
| 221 |
+
function addFlames() {
|
| 222 |
+
// Left paddle flames
|
| 223 |
+
for (let i = 0; i < 3; i++) {
|
| 224 |
+
const flame = document.createElement('div');
|
| 225 |
+
flame.className = 'flame';
|
| 226 |
+
flame.style.left = '-10px';
|
| 227 |
+
flame.style.top = `${20 + i * 30}px`;
|
| 228 |
+
leftPaddle.appendChild(flame);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
// Right paddle flames
|
| 232 |
+
for (let i = 0; i < 3; i++) {
|
| 233 |
+
const flame = document.createElement('div');
|
| 234 |
+
flame.className = 'flame';
|
| 235 |
+
flame.style.right = '-10px';
|
| 236 |
+
flame.style.top = `${20 + i * 30}px`;
|
| 237 |
+
rightPaddle.appendChild(flame);
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
// Create explosion effect
|
| 242 |
+
function createExplosion(x, y) {
|
| 243 |
+
const explosion = document.createElement('div');
|
| 244 |
+
explosion.className = 'explosion';
|
| 245 |
+
explosion.style.left = `${x - 20}px`;
|
| 246 |
+
explosion.style.top = `${y - 20}px`;
|
| 247 |
+
gameContainer.appendChild(explosion);
|
| 248 |
+
|
| 249 |
+
// Create particles
|
| 250 |
+
for (let i = 0; i < 10; i++) {
|
| 251 |
+
const particle = document.createElement('div');
|
| 252 |
+
particle.className = 'particle';
|
| 253 |
+
particle.style.left = `${x - 3}px`;
|
| 254 |
+
particle.style.top = `${y - 3}px`;
|
| 255 |
+
|
| 256 |
+
// Random direction for particles
|
| 257 |
+
const angle = Math.random() * Math.PI * 2;
|
| 258 |
+
const speed = 2 + Math.random() * 5;
|
| 259 |
+
const tx = Math.cos(angle) * speed * 30;
|
| 260 |
+
const ty = Math.sin(angle) * speed * 30;
|
| 261 |
+
|
| 262 |
+
particle.style.setProperty('--tx', `${tx}px`);
|
| 263 |
+
particle.style.setProperty('--ty', `${ty}px`);
|
| 264 |
+
|
| 265 |
+
gameContainer.appendChild(particle);
|
| 266 |
+
|
| 267 |
+
// Remove particles after animation
|
| 268 |
+
setTimeout(() => {
|
| 269 |
+
particle.remove();
|
| 270 |
+
}, 1000);
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
// Remove explosion after animation
|
| 274 |
+
setTimeout(() => {
|
| 275 |
+
explosion.remove();
|
| 276 |
+
}, 500);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
// Update game state
|
| 280 |
+
function update() {
|
| 281 |
+
if (!gameRunning) return;
|
| 282 |
+
|
| 283 |
+
// Move player paddle
|
| 284 |
+
if (keys.w && leftPaddleY > 0) {
|
| 285 |
+
leftPaddleY -= 5;
|
| 286 |
+
}
|
| 287 |
+
if (keys.s && leftPaddleY < gameHeight - paddleHeight) {
|
| 288 |
+
leftPaddleY += 5;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
// Simple AI for right paddle
|
| 292 |
+
const paddleCenter = rightPaddleY + paddleHeight / 2;
|
| 293 |
+
if (paddleCenter < ballY - 10) {
|
| 294 |
+
rightPaddleY += 4;
|
| 295 |
+
} else if (paddleCenter > ballY + 10) {
|
| 296 |
+
rightPaddleY -= 4;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
// Keep AI paddle in bounds
|
| 300 |
+
if (rightPaddleY < 0) rightPaddleY = 0;
|
| 301 |
+
if (rightPaddleY > gameHeight - paddleHeight) rightPaddleY = gameHeight - paddleHeight;
|
| 302 |
+
|
| 303 |
+
// Update paddle positions
|
| 304 |
+
leftPaddle.style.top = `${leftPaddleY}px`;
|
| 305 |
+
rightPaddle.style.top = `${rightPaddleY}px`;
|
| 306 |
+
|
| 307 |
+
// Move ball
|
| 308 |
+
ballX += ballSpeedX;
|
| 309 |
+
ballY += ballSpeedY;
|
| 310 |
+
|
| 311 |
+
// Ball collision with top and bottom
|
| 312 |
+
if (ballY <= 0 || ballY >= gameHeight - ballSize) {
|
| 313 |
+
ballSpeedY = -ballSpeedY;
|
| 314 |
+
createExplosion(ballX, ballY <= 0 ? ballSize : gameHeight - ballSize);
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
// Ball collision with paddles
|
| 318 |
+
if (
|
| 319 |
+
ballX <= 30 + paddleWidth &&
|
| 320 |
+
ballY + ballSize >= leftPaddleY &&
|
| 321 |
+
ballY <= leftPaddleY + paddleHeight
|
| 322 |
+
) {
|
| 323 |
+
ballSpeedX = -ballSpeedX * 1.1; // Increase speed slightly
|
| 324 |
+
ballSpeedY += (ballY - (leftPaddleY + paddleHeight / 2)) * 0.05; // Add angle based on hit position
|
| 325 |
+
createExplosion(30 + paddleWidth, ballY);
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
if (
|
| 329 |
+
ballX >= gameWidth - 30 - paddleWidth - ballSize &&
|
| 330 |
+
ballY + ballSize >= rightPaddleY &&
|
| 331 |
+
ballY <= rightPaddleY + paddleHeight
|
| 332 |
+
) {
|
| 333 |
+
ballSpeedX = -ballSpeedX * 1.1; // Increase speed slightly
|
| 334 |
+
ballSpeedY += (ballY - (rightPaddleY + paddleHeight / 2)) * 0.05; // Add angle based on hit position
|
| 335 |
+
createExplosion(gameWidth - 30 - paddleWidth, ballY);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
// Ball out of bounds (score)
|
| 339 |
+
if (ballX < 0) {
|
| 340 |
+
aiScore++;
|
| 341 |
+
aiScoreDisplay.textContent = `AI: ${aiScore}`;
|
| 342 |
+
resetBall();
|
| 343 |
+
if (aiScore >= 5) endGame(false);
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
if (ballX > gameWidth) {
|
| 347 |
+
playerScore++;
|
| 348 |
+
playerScoreDisplay.textContent = `Player: ${playerScore}`;
|
| 349 |
+
resetBall();
|
| 350 |
+
if (playerScore >= 5) endGame(true);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
// Update ball position
|
| 354 |
+
ball.style.left = `${ballX}px`;
|
| 355 |
+
ball.style.top = `${ballY}px`;
|
| 356 |
+
|
| 357 |
+
// Continue animation
|
| 358 |
+
requestAnimationFrame(update);
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
// Reset ball to center
|
| 362 |
+
function resetBall() {
|
| 363 |
+
ballX = gameWidth / 2 - ballSize / 2;
|
| 364 |
+
ballY = gameHeight / 2 - ballSize / 2;
|
| 365 |
+
ballSpeedX = (Math.random() > 0.5 ? 1 : -1) * 4;
|
| 366 |
+
ballSpeedY = (Math.random() * 4 - 2);
|
| 367 |
+
|
| 368 |
+
// Show ball at center
|
| 369 |
+
ball.style.left = `${ballX}px`;
|
| 370 |
+
ball.style.top = `${ballY}px`;
|
| 371 |
+
|
| 372 |
+
// Pause for a moment
|
| 373 |
+
gameRunning = false;
|
| 374 |
+
setTimeout(() => {
|
| 375 |
+
gameRunning = true;
|
| 376 |
+
update();
|
| 377 |
+
}, 1000);
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
// End game
|
| 381 |
+
function endGame(playerWon) {
|
| 382 |
+
gameRunning = false;
|
| 383 |
+
resultMessage.textContent = playerWon ? "Victory! The Castle Stands!" : "Defeat! The Castle Burns!";
|
| 384 |
+
gameOverScreen.style.display = "flex";
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
// Start game
|
| 388 |
+
function startGame() {
|
| 389 |
+
playerScore = 0;
|
| 390 |
+
aiScore = 0;
|
| 391 |
+
playerScoreDisplay.textContent = "Player: 0";
|
| 392 |
+
aiScoreDisplay.textContent = "AI: 0";
|
| 393 |
+
startScreen.style.display = "none";
|
| 394 |
+
gameOverScreen.style.display = "none";
|
| 395 |
+
resetBall();
|
| 396 |
+
gameRunning = true;
|
| 397 |
+
update();
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
// Event listeners
|
| 401 |
+
document.addEventListener('keydown', (e) => {
|
| 402 |
+
if (e.key.toLowerCase() === 'w') keys.w = true;
|
| 403 |
+
if (e.key.toLowerCase() === 's') keys.s = true;
|
| 404 |
+
});
|
| 405 |
+
|
| 406 |
+
document.addEventListener('keyup', (e) => {
|
| 407 |
+
if (e.key.toLowerCase() === 'w') keys.w = false;
|
| 408 |
+
if (e.key.toLowerCase() === 's') keys.s = false;
|
| 409 |
+
});
|
| 410 |
+
|
| 411 |
+
startButton.addEventListener('click', startGame);
|
| 412 |
+
restartButton.addEventListener('click', startGame);
|
| 413 |
+
|
| 414 |
+
// Initialize
|
| 415 |
+
addFlames();
|
| 416 |
+
</script>
|
| 417 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
|
| 418 |
+
</html>
|