Tripagra commited on
Commit
3891b84
·
1 Parent(s): 56f2dca

Add test endpoint to verify Python functions work

Browse files
Files changed (1) hide show
  1. api/hello.py +27 -0
api/hello.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Simple test endpoint to verify Python functions work on Vercel
3
+ """
4
+
5
+ from http.server import BaseHTTPRequestHandler
6
+ import json
7
+
8
+ class handler(BaseHTTPRequestHandler):
9
+ def do_GET(self):
10
+ self.send_response(200)
11
+ self.send_header('Content-Type', 'application/json')
12
+ self.send_header('Access-Control-Allow-Origin', '*')
13
+ self.end_headers()
14
+
15
+ response = {
16
+ "message": "Hello from Python serverless function!",
17
+ "status": "working"
18
+ }
19
+
20
+ self.wfile.write(json.dumps(response).encode('utf-8'))
21
+
22
+ def do_OPTIONS(self):
23
+ self.send_response(200)
24
+ self.send_header('Access-Control-Allow-Origin', '*')
25
+ self.send_header('Access-Control-Allow-Methods', 'GET, OPTIONS')
26
+ self.send_header('Access-Control-Allow-Headers', 'Content-Type')
27
+ self.end_headers()