python+flask+backend api+Tencent cloud lightweight application server+centos

1. Purchase Tencent Cloud Lightweight Application Server

Tencent Cloud Lightweight Application Server

2. Open ports

open port

3. XShell login server

XShell

4. Backend code

# 实例化 Flask
app = Flask(__name__)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))


# 服务返回
@app.route('/')
def hello_world():
    return "hello world"

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)

5. Test api

Find the public network ip of the server in the Tencent cloud server
and enter: ip:5000 on the browser to access

Guess you like

Origin blog.csdn.net/Bat_Reality/article/details/120536591