verify file
This commit is contained in:
@@ -3,6 +3,15 @@ import json
|
|||||||
def main(args):
|
def main(args):
|
||||||
route = args.get("route")
|
route = args.get("route")
|
||||||
|
|
||||||
|
# Verify file exists, if not create it with default content
|
||||||
|
try:
|
||||||
|
with open("/app/state.json", "r") as f:
|
||||||
|
pass
|
||||||
|
except FileNotFoundError:
|
||||||
|
with open("/app/state.json", "w") as f:
|
||||||
|
json.dump({"text": ""}, f)
|
||||||
|
f.flush()
|
||||||
|
|
||||||
body = args.get("body")
|
body = args.get("body")
|
||||||
body = json.loads(body) if body else {}
|
body = json.loads(body) if body else {}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,30 @@ export function IndexPage() {
|
|||||||
const [text, setText] = useState("");
|
const [text, setText] = useState("");
|
||||||
|
|
||||||
const handleSend = () => {
|
const handleSend = () => {
|
||||||
alert(`You typed: ${text}`);
|
if (text.trim() === "") {
|
||||||
|
alert("Please enter some text before sending.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch("https://shsf-api.reversed.dev/api/exec/15/1c44d8b5-4065-4a54-b259-748561021329/push_text", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ text }),
|
||||||
|
})
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => {
|
||||||
|
if (data.status === "success") {
|
||||||
|
alert("Text sent successfully!");
|
||||||
|
} else {
|
||||||
|
alert("Failed to send text.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error sending text:", error);
|
||||||
|
alert("Error sending text.");
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user