import socket import os import platform import psutil from apiflask import APIBlueprint api = APIBlueprint('api', __name__) @api.get('/hello') def hello(): result_one = f'我是您的专属接口提供服务器: {os.environ["HOSTNAME"]}' result_two = f'我的机器参数如下' result_three = f'操作系统:{platform.system()}' text = """

您好,PZX 大人!
""" + result_one + """
""" + result_two + """
""" + result_three + """
""" + f'CPU 核数:{psutil.cpu_count()},目前 CPU 占用率: {psutil.cpu_percent()}' + """
""" + f'总内存 {round(psutil.virtual_memory().total / 1024 / 1024, 2)} MB,使用中内存:{round(psutil.virtual_memory().used / 1024 / 1024, 2)} MB' + """
""" + f'磁盘总空间 {round(psutil.disk_usage("/").total / 1024 / 1024 / 1024, 2)} G,磁盘使用情况:{round(psutil.disk_usage("/").used / 1024 / 1024 / 1024, 2)} G' + """

""" return text