当前位置:网站首页>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
边栏推荐
- Sword finger offer 46. translate numbers into strings
- 右键新建txt,新建文本文件不见了,通过添加注册表就可以解决,找来找去办法解决不了的终极办法
- [C language] number guessing game + shutdown applet
- 【测试平台开发】二十、完成编辑页发送接口请求功能
- 云呐-如何加强固定资产管理?怎么加强固定资产管理?
- uni-app知识点和项目上遇到的问题和解决办法的记录
- [test platform development] 21. complete sending interface request and display response header information
- Quick introduction to PKI system
- Looking for peak [Abstract dichotomy exercise]
- 运维高级作业03
猜你喜欢

云呐|公司固定资产如何管理?公司固定资产如何管理比较好?

mysql唯一索引无重复值报错重复

Cmake notes

Towhee weekly model

C thread lock and single multithreading are simple to use

Sword finger offer 46. translate numbers into strings

About flex layout justify content: the last solution to the misalignment of space around and why it is solved like this is a discussion

R language practical application case: drawing part (III) - drawing of multiple combination patterns

微信官方出品!小程序自动化框架 minium 分享预告

【测试平台开发】23. 接口断言功能-保存接口断言和编辑回显
随机推荐
自研的数据产品迭代了一年多,为什么不买第三方商业数据平台产品呢?
Uni app knowledge points and records of problems and solutions encountered in the project
21 - 二叉树的垂直遍历
What is per title encoding?
Qt文档阅读笔记-Audio Example解析
Question 142 of Li Kou: circular linked list 2
Advanced operation and maintenance 02
mysql 之general_log日志
固定资产管理系统哪家好?固定资产管理平台有哪些?
【软件测试】如何梳理你测试的业务
It is suggested that Siyuan notes can be compatible with third-party sync disks
关于flex布局justify-content:space-around最后一个不对齐的解决方法和为什么这样子解决是讨论
可以进行2D或3D三角剖分的一些库
Program design of dot matrix Chinese character display of basic 51 single chip microcomputer
[applet automation minium] i. framework introduction and environment construction
4. Find the median of two positive arrays
Authing supports Zadig! Unified authentication and rapid docking of cloud native users
Design and implementation of websocket universal packaging
【C语言】猜数字小游戏+关机小程序
452. Detonate the balloon with the minimum number of arrows