tqhoa commited on
Commit
7d391f9
·
1 Parent(s): 2a8447c

Show cpu name

Browse files
Files changed (1) hide show
  1. main.py +4 -6
main.py CHANGED
@@ -1,16 +1,16 @@
1
  from fastapi import FastAPI, Query
2
  import os
3
  from typing import Any, Optional
4
-
5
 
6
  app = FastAPI(
7
- title="Test Selenium"
8
  )
9
 
10
 
11
  @app.get("/")
12
  def root(
13
- cpu_load: Optional[str] = Query(
14
  False,
15
  description='True/False depending your needs, gets average CPU load value',
16
  regex='^(True|False)$')
@@ -22,8 +22,6 @@ def root(
22
  if cpu_load == 'True':
23
  result["cpu_average_load"] = os.getloadavg()
24
  result["cpu"] = os.cpu_count()
25
-
26
- mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
27
- result["memory"] = mem_bytes/(1024)
28
 
29
  return result
 
1
  from fastapi import FastAPI, Query
2
  import os
3
  from typing import Any, Optional
4
+ import cpuinfo
5
 
6
  app = FastAPI(
7
+ title="Test"
8
  )
9
 
10
 
11
  @app.get("/")
12
  def root(
13
+ show_info: Optional[str] = Query(
14
  False,
15
  description='True/False depending your needs, gets average CPU load value',
16
  regex='^(True|False)$')
 
22
  if cpu_load == 'True':
23
  result["cpu_average_load"] = os.getloadavg()
24
  result["cpu"] = os.cpu_count()
25
+ result["cpu_name"] = cpuinfo.cpu.info[0]['model name']
 
 
26
 
27
  return result