当前位置:网站首页>Three methods of realizing network request in pyodide
Three methods of realizing network request in pyodide
2022-07-19 13:08:00 【InfoQ】
demand
requestsrequestsLib/http.client.pyLib/sockets.py<sys/socket.h>socketmodule.c<sys/socket.h>requestsMethod
1. http.open_url
import pyodide
print(pyodide.http.open_url('https://mocki.io/v1/d4867d8b-b5d5-4a48-a4ab-79131b5809b8').read())
2. http.pyfetch
import pyodide
async def get_data():
response = await pyodide.http.pyfetch('https://mocki.io/v1/d4867d8b-b5d5-4a48-a4ab-79131b5809b8')
data = await response.json()
print(data)
get_data()
# Ask for pictures
response = await pyodide.http.pyfetch('https://gcore.jsdelivr.net/gh/openHacking/[email protected]/img/16576149784751657614977527.png')
# Return the response body as a byte object
image_data = await response.bytes()
3. js Module fetch
import json
from js import fetch,JSON
async def get_data():
response = await fetch('https://mocki.io/v1/d4867d8b-b5d5-4a48-a4ab-79131b5809b8',{'method':'GET'})
data = await response.json()
print(JSON.stringify(data))
await get_data()
summary
Reference resources
- Pyodide To realize the network request 3 Methods
- pyodide python api
- pyodide.http.open_url
- pyodide.http.pyfetch
- pyodide.runPythonAsync
- pyodide - requests module is not available #398
边栏推荐
- RingBuffer
- LeetCode 0117. Populate the next right node pointer II of each node
- Which domestic API tool is better? It turned out to be it
- Nombre minimal d'échanges
- Audio common terminal anatomy - never make a mistake again
- 2022全球开发者薪资曝光:中国排第19名,平均年薪23,790美元
- Is it safe for Everbright futures to open an account online? Are there any account opening guidelines?
- Arbitrum Nova release! Create a low-cost and high-speed dedicated chain in the game social field
- 市场“不确定性”中的投资逻辑 2020-03-18
- 力扣198-213 打家劫舍Ⅰ、Ⅱ——动态规划
猜你喜欢

Arbitrum Nova release! Create a low-cost and high-speed dedicated chain in the game social field

LeetCode 0565.数组嵌套:转换为图 + 原地修改の优化

AE如何制作星云粒子特效

Reg of sequential logic and combinatorial logic

Panasonic A6 servo driver external absolute value grating ruler full closed loop parameter setting
[email protected] )|Rhodamine 6G modified MOF material | catalase @zif composite | MOF"/>Lanthanide metal organic skeleton( [email protected] )|Rhodamine 6G modified MOF material | catalase @zif composite | MOF

Return to risk ratio: the most important indicator of investment opportunities 2020-03-14

Uio-66 | fe3o4/cu3 (BTC) 2 metal organic framework (MOF) nanocomposites supported on silver nanoparticles | nagdf4:yb, er upconversion nanoparticles @zif-8

【Pygame 学习笔记】6.Cursor 鼠标光标

C语言进阶——自定义类型:结构体 枚举 联合
随机推荐
Li Kou 70 - climbing stairs - Dynamic Planning
506. Relative ranking
AI is the designer who knows you best? Let users generate digital clothing "by heart" Adidas ozworld
Supported metal organic framework zif-8 / graphene oxide hydrogen storage material | titanium dioxide /zif-8 composite | silicon dioxide @zif8 nano material
Metal organic framework / nitrogen carbide nano sheet (uio-66/hocn) composite | mil-101 loaded Au Pd alloy nanoparticles | chemical reagent MOF customization
Mysql database tables add fields, delete fields, modify the arrangement of fields and other operations, but not soon
The latest Jilin construction safety officer simulation question bank and answers in 2022
面试难题:分布式 Session 实现难点,这篇就够!
Useeffect summary
时序逻辑与组合逻辑的reg
Li Kou 413 division of equal difference sequence dynamic programming
Porphyrin encapsulated organometallic frame materials [email protected] |
关于“抄底”心态,让你筋疲力尽 2020-03-15
Possible problems in inserting Excel data into MySQL database
逻辑运算符1(阁瑞钛伦特软件-九耶实训)
Security measures for tcp/ip protocol vulnerabilities
Investment logic in market "uncertainty" 2020-03-18
LeetCode 0118. Yanghui triangle
Mysql的知识梳理
VIM strange unknown function 0