Update app.py
Browse files
app.py
CHANGED
|
@@ -141,7 +141,7 @@ def saveToMarket(payload):
|
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
-
def UpdateMarketData(
|
| 145 |
|
| 146 |
|
| 147 |
call_success = 200 <= status_code < 300
|
|
@@ -150,9 +150,7 @@ def UpdateMarketData(resource,endpoint,endpoint_linker,endpoint_method,status_co
|
|
| 150 |
{ "owner": "system" },
|
| 151 |
{
|
| 152 |
"$set": {
|
| 153 |
-
"market.$[elem].
|
| 154 |
-
"endpoint_method":endpoint_method,
|
| 155 |
-
"resource":resource
|
| 156 |
},
|
| 157 |
"$inc": {
|
| 158 |
"market.$[elem].calls": 1,
|
|
@@ -165,6 +163,10 @@ def UpdateMarketData(resource,endpoint,endpoint_linker,endpoint_method,status_co
|
|
| 165 |
|
| 166 |
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
#GET requests proxy
|
| 169 |
async def X402Proxy_GET(request: Request, endpoint: str):
|
| 170 |
async with httpx.AsyncClient() as client:
|
|
@@ -309,9 +311,8 @@ def RegisterEndpoint(data:RegisterPayload):
|
|
| 309 |
"endpoint_linker":short_id_e,
|
| 310 |
"meta":data.meta,
|
| 311 |
"description":data.description,
|
| 312 |
-
"endpoint":"",
|
| 313 |
"endpoint_method":"",
|
| 314 |
-
|
| 315 |
"calls":0,
|
| 316 |
"failures":0
|
| 317 |
|
|
@@ -359,18 +360,19 @@ def RegisterDynamicEndpoint(data:RegisterPayloadDynamic):
|
|
| 359 |
)
|
| 360 |
|
| 361 |
|
|
|
|
| 362 |
marketpayload={
|
| 363 |
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
"endpoint":"",
|
| 369 |
"endpoint_method":"",
|
| 370 |
-
"
|
| 371 |
"calls":0,
|
| 372 |
-
|
| 373 |
-
|
|
|
|
| 374 |
}
|
| 375 |
|
| 376 |
|
|
@@ -603,7 +605,7 @@ async def FetchVelocityGET(x402id:str,request:Request):
|
|
| 603 |
#proxying here
|
| 604 |
|
| 605 |
response=await X402Proxy_GET(request,found_endpoint)
|
| 606 |
-
UpdateMarketData(
|
| 607 |
|
| 608 |
|
| 609 |
|
|
@@ -858,7 +860,7 @@ async def FetchVelocityPost(request:Request):
|
|
| 858 |
updateInvoice(owner=wallet,endpoint_linker=x402id,data=invoicePayload)
|
| 859 |
#proxying here
|
| 860 |
response=await X402Proxy_POST(request,found_endpoint)
|
| 861 |
-
UpdateMarketData(
|
| 862 |
|
| 863 |
|
| 864 |
|
|
|
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
+
def UpdateMarketData(endpoint_method,status_code):
|
| 145 |
|
| 146 |
|
| 147 |
call_success = 200 <= status_code < 300
|
|
|
|
| 150 |
{ "owner": "system" },
|
| 151 |
{
|
| 152 |
"$set": {
|
| 153 |
+
"market.$[elem].endpoint_method":endpoint_method,
|
|
|
|
|
|
|
| 154 |
},
|
| 155 |
"$inc": {
|
| 156 |
"market.$[elem].calls": 1,
|
|
|
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
|
| 170 |
#GET requests proxy
|
| 171 |
async def X402Proxy_GET(request: Request, endpoint: str):
|
| 172 |
async with httpx.AsyncClient() as client:
|
|
|
|
| 311 |
"endpoint_linker":short_id_e,
|
| 312 |
"meta":data.meta,
|
| 313 |
"description":data.description,
|
|
|
|
| 314 |
"endpoint_method":"",
|
| 315 |
+
"endpoint_mcp_base:"https://mcpv100-production.up.railway.app/mcp:8080",
|
| 316 |
"calls":0,
|
| 317 |
"failures":0
|
| 318 |
|
|
|
|
| 360 |
)
|
| 361 |
|
| 362 |
|
| 363 |
+
|
| 364 |
marketpayload={
|
| 365 |
|
| 366 |
+
"owner":data.owner,
|
| 367 |
+
"endpoint_linker":short_id_e,
|
| 368 |
+
"meta":data.meta,
|
| 369 |
+
"description":data.description,
|
|
|
|
| 370 |
"endpoint_method":"",
|
| 371 |
+
"endpoint_mcp_base:"https://mcpv100-production.up.railway.app/mcp:8080",
|
| 372 |
"calls":0,
|
| 373 |
+
"failures":0
|
| 374 |
+
|
| 375 |
+
|
| 376 |
}
|
| 377 |
|
| 378 |
|
|
|
|
| 605 |
#proxying here
|
| 606 |
|
| 607 |
response=await X402Proxy_GET(request,found_endpoint)
|
| 608 |
+
UpdateMarketData("GET",response.status_code)
|
| 609 |
|
| 610 |
|
| 611 |
|
|
|
|
| 860 |
updateInvoice(owner=wallet,endpoint_linker=x402id,data=invoicePayload)
|
| 861 |
#proxying here
|
| 862 |
response=await X402Proxy_POST(request,found_endpoint)
|
| 863 |
+
UpdateMarketData("POST",response.status_code)
|
| 864 |
|
| 865 |
|
| 866 |
|