当前位置:网站首页>Fastapi application joins Nacos
Fastapi application joins Nacos
2022-07-23 14:53:00 【Hengyunke】
Recently, there is a project that needs to work with sap Communications Adopted web service,
To facilitate communication To give up java Request , Direct use Fastapi Realization
import nacos
import uvicorn
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from suds.client import Client
from suds.transport.https import HttpAuthenticated
client=nacos.NacosClient('172.16.244.200:8848',namespace='8b6f08b7-b09c-4181-bcac-1505fba5e1aa')
async def beat():
client.add_naming_instance('fastapi-service','172.16.244.10',8000,group_name='dev')
# Microservice registration nacos
def register_nacos():
client.add_naming_instance('fastapi-service','172.16.244.10',8000,group_name='dev')
app=FastAPI()
# Microservice registration
register_nacos()
@app.on_event('startup')
def init_scheduler():
scheduler = AsyncIOScheduler(timezone="Asia/Shanghai")
scheduler.add_job(beat, 'interval', seconds=5)
scheduler.start()
@app.get('/sap/materials')
async def sap_materials():
''' Function realization '''
return JSONResponse({'code':1000,'msg':'succ','data':data},status_code=200)Some points to pay attention to
group_name To work with others java The micro service configuration should be consistent Incorrect writing spring cloud gateway Tips 404 error
timezone='Asia/Shangai' The time zone will be prompted when starting without utc

The results

In terms of efficiency fastapi From development to deployment, it took 1 Days to solve the problem
边栏推荐
- C language implementation of classroom random roll call system
- 452. Detonate the balloon with the minimum number of arrows
- @Feignclient detailed tutorial (illustration)
- Feignclient utilise un tutoriel détaillé (illustration)
- 运维高级作业03
- Mathematical function of MySQL function summary
- @FeignClient使用詳細教程(圖解)
- [can I do your first project?] Detailed introduction and Simulation Implementation of gzip
- mysql函数汇总之字符串函数
- 452. 用最少数量的箭引爆气球
猜你喜欢

固定资产管理系统哪家好?固定资产管理平台有哪些?
![[array & String & Macro exercise]](/img/44/26debc1ee958277935e73a75d894d4.png)
[array & String & Macro exercise]

什麼是Per-Title編碼?

Opencv calculation outsourcing rectangle

Detailed tutorial of typora drawing bed configuration

cmake笔记
![[test platform development] XVII. The interface editing page realizes the drop-down cascade selection, and binds the module to which the interface belongs](/img/19/de8f4de5adbfcfb62291b8664187fd.png)
[test platform development] XVII. The interface editing page realizes the drop-down cascade selection, and binds the module to which the interface belongs

【我可以做你的第一个项目吗?】GZIP的细节简介和模拟实现

Cmake notes

Sword finger offer19 regular expression
随机推荐
【小程序自动化Minium】三、元素定位- WXSS 选择器的使用
Sword finger offer 46. translate numbers into strings
Openharmony South learning notes - hi3861+hc-sr04 ultrasonic testing
转自玉溪信息公开:mRNA新冠疫苗、九洲马破伤风免疫球蛋白等产品有望年内上市。
The win11 installation system prompts that VirtualBox is incompatible and needs to uninstall the solution of virtual, but the uninstall list cannot find the solution of virtual
OpenHarmony南向学习笔记——Hi3861+HC-SR04超声波检测
21 - vertical traversal of binary tree
Dynamic programming -- knapsack problem
【刷题记录】19. 删除链表的倒数第 N 个结点
CSDN writing method (II)
[software testing] how to sort out your testing business
It is suggested that Siyuan notes can be compatible with third-party sync disks
【C語言】猜數字小遊戲+關機小程序
数字相加的精度问题
win11安装系统提示virtualBox不兼容需要卸载virtual的解决办法,但是卸载列表找不到virtual的解决办法
[can I do your first project?] Detailed introduction and Simulation Implementation of gzip
Is it risky and safe to open an account for stock speculation?
@FeignClient使用詳細教程(圖解)
uni-app知识点和项目上遇到的问题和解决办法的记录
身份证号正则验证