minimal python requests externs

This commit is contained in:
2021-07-31 21:57:30 -06:00
parent 2013ebcc5e
commit e36e05cf98
7 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
-lib kiss
-cp src
--main requests_externs.Main
--python bin/main.py
--cmd python bin/main.py

View File

@@ -0,0 +1,17 @@
{
"main": "requests_externs.Main",
"name": "requests-externs",
"description": "barebones python requests",
"classPath": "src/",
"dependencies": {
"kiss": ""
},
"url": "https://github.com/NQNStudios/kisslang",
"contributors": [
"NQNStudios"
],
"version": "0.0.0",
"releasenote": "",
"tags": [],
"license": "LGPL"
}

View File

@@ -0,0 +1,8 @@
package requests_externs;
import kiss.Kiss;
import kiss.Prelude;
import requests_externs.Requests;
@:build(kiss.Kiss.build())
class Main {}

View File

@@ -0,0 +1 @@
~(Requests.get "https://google.com/search" [=>"q" "test"] /*(object)*/)

View File

@@ -0,0 +1,25 @@
package requests_externs;
import haxe.extern.EitherType;
import python.Dict;
import python.KwArgs;
import requests_externs.Response;
typedef RequestKwArgs = {
?headers:Map<String, String>
}
@:pythonImport("requests")
extern class NativeRequests {
public static function get(url:String, params:Dict<String, String>, ?kwArgs:KwArgs<RequestKwArgs>):Response;
}
class Requests {
public static function get(url:String, params:Map<String, String>, ?kwArgs:KwArgs<RequestKwArgs>):Response {
var dict = new Dict<String, String>();
for (param => value in params) {
dict.set(param, value);
}
return NativeRequests.get(url, dict, kwArgs);
}
}

View File

@@ -0,0 +1,4 @@
package requests_externs;
@:pythonImport("requests.Response")
extern class Response {}

View File

@@ -0,0 +1,3 @@
#! /bin/bash
haxe build.hxml