TenPoisk
commited on
Commit
·
7328589
1
Parent(s):
b6191f7
Rename index.html to URLcut.html
Browse files- URLcut.html +49 -0
- index.html +0 -19
URLcut.html
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>CofURL.cut</title>
|
5 |
+
<p></p>
|
6 |
+
</head>
|
7 |
+
<body>
|
8 |
+
<h1>• CofURLcut</h1>
|
9 |
+
<label for="long-url">• Enter a long link:</label>
|
10 |
+
<p></p>
|
11 |
+
<input type="text" id="long-url" placeholder="https://internet.com">
|
12 |
+
<p></p>
|
13 |
+
<button id="shorten-button">Shorten</button>
|
14 |
+
<br>
|
15 |
+
<p></p>
|
16 |
+
<label for="short-url">• Short link:</label>
|
17 |
+
<p></p>
|
18 |
+
<input type="text" id="short-url" readonly>
|
19 |
+
<p></p>
|
20 |
+
<script>
|
21 |
+
document.getElementById("shorten-button").addEventListener("click", function() {
|
22 |
+
var longUrl = document.getElementById("long-url").value;
|
23 |
+
|
24 |
+
// Выполнение запроса к API Bit.ly для сокращения ссылки
|
25 |
+
fetch("https://api-ssl.bitly.com/v4/shorten", {
|
26 |
+
method: "POST",
|
27 |
+
headers: {
|
28 |
+
"Content-Type": "application/json",
|
29 |
+
"Authorization": "326c6f40970f20b2e71669323f7849575789630b"
|
30 |
+
},
|
31 |
+
body: JSON.stringify({
|
32 |
+
long_url: longUrl
|
33 |
+
})
|
34 |
+
})
|
35 |
+
.then(response => response.json())
|
36 |
+
.then(data => {
|
37 |
+
var shortUrl = data.link;
|
38 |
+
document.getElementById("short-url").value = shortUrl;
|
39 |
+
})
|
40 |
+
.catch(error => {
|
41 |
+
console.error(error);
|
42 |
+
document.getElementById("short-url").value = "Ошибка при сокращении ссылки.";
|
43 |
+
});
|
44 |
+
});
|
45 |
+
</script>
|
46 |
+
<p></p>
|
47 |
+
• Link shortener
|
48 |
+
</body>
|
49 |
+
</html>
|
index.html
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html>
|
3 |
-
<head>
|
4 |
-
<meta charset="utf-8" />
|
5 |
-
<meta name="viewport" content="width=device-width" />
|
6 |
-
<title>My static Space</title>
|
7 |
-
<link rel="stylesheet" href="style.css" />
|
8 |
-
</head>
|
9 |
-
<body>
|
10 |
-
<div class="card">
|
11 |
-
<h1>Welcome to your static Space!</h1>
|
12 |
-
<p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
|
13 |
-
<p>
|
14 |
-
Also don't forget to check the
|
15 |
-
<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
|
16 |
-
</p>
|
17 |
-
</div>
|
18 |
-
</body>
|
19 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|