Skip to content

Commit

Permalink
🚀 : Add Appwrite Functionality for LangX Copilot with POST Request Su…
Browse files Browse the repository at this point in the history
…pport

Fixes #6
  • Loading branch information
xuelink committed May 28, 2024
1 parent 1351ab0 commit 07a5307
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { handleInteraction } from "./copilot/aiHandler.js";

export default async function ({ req, res, log, error }) {
try {
// Log a message
Expand All @@ -12,6 +14,11 @@ export default async function ({ req, res, log, error }) {
if (req.method === "GET") {
// Send a JSON response
return res.json({ message: "Hello, World!" });
} else if (req.method === "POST") {
// Handle POST request
const userMessage = req.body.message;
const aiResponse = await handleInteraction(userMessage);
return res.json({ response: aiResponse });
} else {
// Handle other HTTP methods if necessary
return res.send("Unsupported request method", 405);
Expand Down

0 comments on commit 07a5307

Please sign in to comment.