-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.php
More file actions
35 lines (25 loc) · 676 Bytes
/
Copy pathpost.php
File metadata and controls
35 lines (25 loc) · 676 Bytes
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
<?php
// $_
// Sample JSON data
$form_data = $_POST;
$post_fields = http_build_query($form_data);
$headers = getallheaders();
$curl_headers = array();
foreach ($headers as $key => $value) {
$curl_headers[] = "$key: $value";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost:5000/');
// curl_setopt is a function that sets options for the cURL request.
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response) {
// print_r($decodedBody);
echo $response;
}
else{
echo "flask server down";
}
?>