代码拉取完成,页面将自动刷新
pip install utran
import utran
from utran.server import Server,HttpResponse
server = Server()
@server.register.get('/')
def sayhi():
return HttpResponse(text="hi,Utran!",content_type='text/html')
@server.register.rpc
async def add(a:int,b:int):
return a+b
utran.run(server,host='127.0.0.1',port=8081,web_port=8080)
import utran
client = utran.Client(url='ws://127.0.0.1:8081')
res = client.call.add(1,2)
print(res)
client.exit()
import utran
client = utran.Client(url='ws://127.0.0.1:8081')
@client
def main():
res = client.call.add(1,2)
print(res)
import utran
client = utran.Client(url='ws://127.0.0.1:8081')
@client
async def main():
res = await client.call.add(1,2)
print(res)
import utran
with utran.Client(url='ws://127.0.0.1:8081') as client:
res = client.call.add(1,2)
print(res)
import utran
async with utran.Client(url='ws://127.0.0.1:8081') as client:
res = await client.call.add(1,2)
print(res)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。