kopia lustrzana https://github.com/learn-awesome/learndb
moved everything into the same folder
rodzic
9f0821905d
commit
4dcfe72834
|
@ -0,0 +1,128 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Invoke Netlify Function</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
max-width: 400px;
|
||||||
|
width: 100%;
|
||||||
|
text-align: left; /* Left-align form elements */
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
color: #555;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"] {
|
||||||
|
background-color: #3fbfff;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
padding: 12px 24px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 0 auto; /* Center the button horizontally */
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"]:hover {
|
||||||
|
background-color: #1177e4;
|
||||||
|
}
|
||||||
|
|
||||||
|
#result {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: transparent;
|
||||||
|
border: none;
|
||||||
|
max-width: 400px;
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap; /* Prevent wrapping to the next line */
|
||||||
|
overflow: hidden; /* Hide the overflow */
|
||||||
|
text-align: center; /* Center-align text in result div */
|
||||||
|
margin-left: auto; /* Move to the center horizontally */
|
||||||
|
margin-right: auto; /* Move to the center horizontally */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Invoke Netlify Function</h1>
|
||||||
|
<form id="invokeForm" action="https://main--radiant-entremet-3fce83.netlify.app/.netlify/functions/handleMetadata" method="POST" onsubmit="invokeFunction(event)">
|
||||||
|
<label for="url">URL:</label>
|
||||||
|
<input type="text" id="url" name="url" value="https://example.com">
|
||||||
|
|
||||||
|
<label for="apiKey">API Key:</label>
|
||||||
|
<input type="text" id="apiKey" name="apiKey" value="your-api-key">
|
||||||
|
|
||||||
|
<div class="button-container">
|
||||||
|
<input type="submit" value="Invoke Function">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div id="result"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
async function invokeFunction(event) {
|
||||||
|
event.preventDefault(); // Prevent the default form submission behavior
|
||||||
|
|
||||||
|
const url = document.getElementById("url").value;
|
||||||
|
const apiKey = document.getElementById("apiKey").value;
|
||||||
|
|
||||||
|
const formData = { url, apiKey };
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch("https://main--radiant-entremet-3fce83.netlify.app/.netlify/functions/handleMetadata", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify(formData)
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
// Display the result in the "result" div
|
||||||
|
document.getElementById("result").innerHTML = JSON.stringify(data, null, 2);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,2 @@
|
||||||
|
[build]
|
||||||
|
functions = "netlify/functions/"
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "handle-metadata-function",
|
"name": "handle-metadata-function",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"openai": "^4.20.0"
|
"openai": "4.20.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
Ładowanie…
Reference in New Issue