Close #2
import http.server
import socketserver
import json
PORT = 8000
class MyHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "application/json")
self.end_headers()
data = {"message": "Hello from the Python server!", "status": "success"}
self.wfile.write(json.dumps(data).encode("utf-8"))
with socketserver.TCPServer(("", PORT), MyHandler) as httpd:
print(f"Serving at port {PORT}")
httpd.serve_forever()
This commit is contained in:
23
dm-cli/.vscode/Untitled-1.json
vendored
Normal file
23
dm-cli/.vscode/Untitled-1.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"order": "feedback",
|
||||||
|
"type": "Postpayment",
|
||||||
|
"at": "https://testnet-dm2.bitdeals.org",
|
||||||
|
"date": "2025-11-24 13:56:04 UTC",
|
||||||
|
"salt": "ab4a60c3",
|
||||||
|
"seller": {
|
||||||
|
"address": "mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp"
|
||||||
|
},
|
||||||
|
"customer": {
|
||||||
|
"address": "mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC",
|
||||||
|
"signature": "HxcVlEuqV5G3FUW6Ter553DmtcxTT7DWBUtSO5mn+DS1MZzEwLcLwEYWXJSbtphHKYCQU3EZTkWPfBaOFA2kxhU="
|
||||||
|
},
|
||||||
|
"payment": {
|
||||||
|
"address": "2Mzc3G6oKce8WHxSWF9eJ826swAGHD4Ftzi",
|
||||||
|
"until": "2025-11-25 13:56:04 UTC",
|
||||||
|
"sum": "0.01 tBTC"
|
||||||
|
},
|
||||||
|
"feedback": {
|
||||||
|
"leave-before": "2025-12-08 13:56:04 UTC",
|
||||||
|
"comments": "message_text"
|
||||||
|
}
|
||||||
|
}
|
||||||
27
dm-cli/.vscode/Untitled-2.json
vendored
Normal file
27
dm-cli/.vscode/Untitled-2.json
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"order": "feedback",
|
||||||
|
"type": "Postpayment",
|
||||||
|
"at": "https://testnet-dm2.bitdeals.org",
|
||||||
|
"date": "2025-11-24 13:56:04",
|
||||||
|
"salt": "ab4a60c3",
|
||||||
|
"code": "5d432facab0f33c3859c01dfa2fd28c0a9742e4a",
|
||||||
|
"seller": {
|
||||||
|
"address": "mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp",
|
||||||
|
"rating": "0+, 30%"
|
||||||
|
},
|
||||||
|
"customer": {
|
||||||
|
"address": "mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC",
|
||||||
|
"rating": "0+, 36%",
|
||||||
|
"signature": "HxcVlEuqV5G3FUW6Ter553DmtcxTT7DWBUtSO5mn+DS1MZzEwLcLwEYWXJSbtphHKYCQU3EZTkWPfBaOFA2kxhU="
|
||||||
|
},
|
||||||
|
"payment": {
|
||||||
|
"address": "2Mzc3G6oKce8WHxSWF9eJ826swAGHD4Ftzi",
|
||||||
|
"sum": "0.01 tBTC",
|
||||||
|
"until": "2025-11-25 13:56:04"
|
||||||
|
},
|
||||||
|
"feedback": {
|
||||||
|
"comments": "negative mgs",
|
||||||
|
"leave_before": "2025-12-08 13:56:04",
|
||||||
|
"status": "Negative"
|
||||||
|
}
|
||||||
|
}
|
||||||
7
dm-cli/.vscode/launch.json
vendored
7
dm-cli/.vscode/launch.json
vendored
@@ -7,6 +7,7 @@
|
|||||||
//--debug --address https://testnet-dm2.bitdeals.org deal create -t prepayment -s mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp -c mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC -g 0.01
|
//--debug --address https://testnet-dm2.bitdeals.org deal create -t prepayment -s mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp -c mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC -g 0.01
|
||||||
// dm-cli --debug deal complete --positive 2MwPWCkWuqsigNu7YPrA5eStUUD6LvyHQTd
|
// dm-cli --debug deal complete --positive 2MwPWCkWuqsigNu7YPrA5eStUUD6LvyHQTd
|
||||||
// -m "feedback_message" -s "Hxhv4ewOOVGbydibNzdNxaWPDkFhDi0N3rdXtPVe5YtkfR2RECUG5KebcRCBmgN94t/NVYBOo/ft/FN1q6p42l8=" 2NAFmjLid526kjekoMiCm8nX5SxFCfk7jgC
|
// -m "feedback_message" -s "Hxhv4ewOOVGbydibNzdNxaWPDkFhDi0N3rdXtPVe5YtkfR2RECUG5KebcRCBmgN94t/NVYBOo/ft/FN1q6p42l8=" 2NAFmjLid526kjekoMiCm8nX5SxFCfk7jgC
|
||||||
|
// curl --location 'https://testnet-dm.bitdeals.org/api/v1/deal/feedback?server=https%3A%2F%2Ftestnet.bitdeals.org'
|
||||||
|
|
||||||
|
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
@@ -23,10 +24,10 @@
|
|||||||
"deal",
|
"deal",
|
||||||
"negative",
|
"negative",
|
||||||
"-m",
|
"-m",
|
||||||
"negative mgs",
|
"message_text",
|
||||||
"-s",
|
"-s",
|
||||||
"Hxhv4ewOOVGbydibNzdNxaWPDkFhDi0N3rdXtPVe5YtkfR2RECUG5KebcRCBmgN94t/NVYBOo/ft/FN1q6p42l8=",
|
"HxcVlEuqV5G3FUW6Ter553DmtcxTT7DWBUtSO5mn+DS1MZzEwLcLwEYWXJSbtphHKYCQU3EZTkWPfBaOFA2kxhU=",
|
||||||
"2NAFmjLid526kjekoMiCm8nX5SxFCfk7jgC"
|
"2Mzc3G6oKce8WHxSWF9eJ826swAGHD4Ftzi"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,33 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
string url_encode(const string &value)
|
||||||
|
{
|
||||||
|
ostringstream escaped;
|
||||||
|
escaped.fill('0');
|
||||||
|
escaped << hex;
|
||||||
|
|
||||||
|
for (string::const_iterator i = value.begin(), n = value.end(); i != n; ++i)
|
||||||
|
{
|
||||||
|
string::value_type c = (*i);
|
||||||
|
|
||||||
|
// Keep alphanumeric and other accepted characters intact
|
||||||
|
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~')
|
||||||
|
{
|
||||||
|
escaped << c;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Any other characters are percent-encoded
|
||||||
|
escaped << uppercase;
|
||||||
|
escaped << '%' << setw(2) << int((unsigned char)c);
|
||||||
|
escaped << nouppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
return escaped.str();
|
||||||
|
}
|
||||||
|
|
||||||
int Deals::HelpCreate() const
|
int Deals::HelpCreate() const
|
||||||
{
|
{
|
||||||
if (isRussian)
|
if (isRussian)
|
||||||
@@ -234,6 +261,12 @@ int Deals::Status()
|
|||||||
{
|
{
|
||||||
string data = CommonStatus();
|
string data = CommonStatus();
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
|
if (isDebug)
|
||||||
|
{
|
||||||
|
cout << "command line" << endl;
|
||||||
|
cout << data << endl;
|
||||||
|
cout << result << endl;
|
||||||
|
}
|
||||||
if (result.length() == 0)
|
if (result.length() == 0)
|
||||||
return NoResponse("");
|
return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
@@ -377,7 +410,7 @@ int Deals::Negative()
|
|||||||
return NoResponse("");
|
return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
nlohmann::json deal = jsonData["deal"];
|
nlohmann::json deal = jsonData["deal"];
|
||||||
|
nlohmann::ordered_json deal2;
|
||||||
string message;
|
string message;
|
||||||
string sign;
|
string sign;
|
||||||
if (parser.cmdOptionExists("-m") || parser.cmdOptionExists("--message"))
|
if (parser.cmdOptionExists("-m") || parser.cmdOptionExists("--message"))
|
||||||
@@ -389,22 +422,38 @@ int Deals::Negative()
|
|||||||
sign = GetVal("-s", "--signature");
|
sign = GetVal("-s", "--signature");
|
||||||
}
|
}
|
||||||
|
|
||||||
deal["customer"]["signature"] = sign;
|
deal2["order"] = "feedback";
|
||||||
deal["feedback"]["comments"] = message;
|
deal2["type"] = deal["type"];
|
||||||
deal["order"] = "feetback";
|
deal2["at"] = deal["at"];
|
||||||
|
deal2["date"] = deal["date"];
|
||||||
|
deal2["salt"] = deal["salt"];
|
||||||
|
|
||||||
deal["date"] = Replace(deal["date"], " UTC", "");
|
// deal2["seller"] = "{}";
|
||||||
deal["feedback"]["leave_before"] = Replace(deal["feedback"]["leave_before"], " UTC", "");
|
deal2["seller"]["address"] = deal["seller"]["address"];
|
||||||
deal["payment"]["until"] = Replace(deal["payment"]["until"], " UTC", "");
|
|
||||||
|
|
||||||
string jsf = deal.dump();
|
// deal2["customer"] = "{}";
|
||||||
jsf = ReplaceAll(jsf, "\"", "\\\"");
|
deal2["customer"]["address"] = deal["customer"]["address"];
|
||||||
data = "curl -s -X POST \"";
|
deal2["customer"]["signature"] = sign;
|
||||||
|
|
||||||
|
deal2["payment"]["address"] = deal["payment"]["address"];
|
||||||
|
deal2["payment"]["until"] = deal["payment"]["until"];
|
||||||
|
deal2["payment"]["sum"] = deal["payment"]["sum"];
|
||||||
|
|
||||||
|
// deal2["feedback"] = "{}";
|
||||||
|
deal2["feedback"]["leave_before"] = deal["feedback"]["leave_before"];
|
||||||
|
deal2["feedback"]["comments"] = message;
|
||||||
|
|
||||||
|
string jsf = deal2.dump();
|
||||||
|
jsf = ReplaceAll(jsf, "leave_before", "leave-before");
|
||||||
|
data = "curl --location '";
|
||||||
data.append(address);
|
data.append(address);
|
||||||
data.append("/api/v1/deal/feedback\" -H \"Content-Type: application/json\" ");
|
data.append("/api/v1/deal/feedback?server=");
|
||||||
data.append("-d \"");
|
data.append(url_encode(address));
|
||||||
|
data.append("'");
|
||||||
|
data.append(" --header 'Content-Type: application/json' ");
|
||||||
|
data.append("--data '");
|
||||||
data.append(jsf);
|
data.append(jsf);
|
||||||
data.append("\"");
|
data.append("'");
|
||||||
|
|
||||||
result = ExecCommand(data.c_str());
|
result = ExecCommand(data.c_str());
|
||||||
if (result.length() == 0)
|
if (result.length() == 0)
|
||||||
|
|||||||
24477
dm-cli/json.hpp
24477
dm-cli/json.hpp
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user