python注册nacos微服并使用gateway网关

业务需求:使用python flask框架和java spring boot框架共同注册到nacos中,在由spring cloud gateway分配路由。

flaskDome:

from flask import Flask

app = Flask(__name__)


@app.route('/python')
def test():
    return "这是python flask框架接口,您调用成功"


if __name__ == '__main__':
    app.run(host='127.0.0.1',port=8080 )
    

接口路由:localhost:8080/python

python服务注册:

import threading
import time
import requests
import json


def register():
    //服务所在ip和端口号、服务名称
    params = {'ip': '127.0.0.1', 'port': '8080','serviceName':'service-prediction-ai'}
    //服务器nacos地址
    url = "http://localhost:8848/nacos/v1/ns/instance"
    res = requests.post(url, params=params)
    print("注册状态:&

你可能感兴趣的:(gateway,java,spring,boot,flask)