horatiothomas-dream_interpreter_journal_dictionary.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
export default async function handler(request: Request) {
if (request.method === "GET") {
return new Response(
`<!DOCTYPE html>
<html>
<head>
<title>Dream Interpreter</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.0.3/dist/tailwind.min.css" rel="stylesheet">
<script>
function handleSubmit(event) {
event.preventDefault();
var dreamInput = document.getElementById('dreamInput');
var dream = dreamInput.value;
var interpretationDiv = document.getElementById('interpretation');
fetch(window.location.href, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ dream }),
})
.then(response => response.json())
.then(data => {
interpretationDiv.textContent = data.dream;
})
.catch(error => {
console.error('Error:', error);
});
}
</script>
</head>
<body class="p-4">
<h1>Dream Interpreter</h1>
<form onsubmit="handleSubmit(event)">
<input id="dreamInput" type="text" placeholder="Enter your dream" class="border-2 border-gray-200 p-2 rounded-md w-full" />
<button type="submit" class="bg-blue-500 text-white p-2 rounded-md mt-2">Interpret Dream</button>
</form>
<div id="interpretation" class="mt-4"></div>
</body>
</html>`,
{
headers: {
"Content-Type": "text/html",
"Cache-Control": "public, max-age=10, stale-while-revalidate=0",
},
},
);
} else if (request.method === "POST") {
try {
const body = await request.json();
const dream = body.dream;
// Generate a random UUID
const randomUuid = () => {
let uuid = "";
for (let i = 0; i < 32; i++) {
const random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) {
uuid += "-";
}
uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16);
}
return uuid;
};
// Create the request payload
const payload = {
dream,
lat: null,
long: null,
};
// Send the POST request
const response = await fetch("https://dreaminterpreteraibackend.com/dream", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.9",
"Country": "US",
"Language": "en",
"Origin": "https://www.dreaminterpreter.ai",
"Referer": "https://www.dreaminterpreter.ai/",
"Sec-Ch-Ua": "\"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"macOS\"",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"Uid": randomUuid(),
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
},
body: JSON.stringify(payload),
});
// Handle the response
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 24, 2024