- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
Latest commit
34 lines (24 loc) · 867 Bytes
/
Copy pathserver.py
File metadata and controls
34 lines (24 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fromflaskimportFlask, request
app=Flask(__name__)
importsocket, subprocess
seed_value=0
app=Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
defroute():
globalseed_value
ret='SUCCESS'
ifrequest.method=='POST':
content=request.json
if'num'incontent:
seed_value=content['num']
command='python3 stress_cpu.py '+str(seed_value)
try :
result=subprocess.Popen(['/home/ubuntu/MP2/stress_cpu.py', str(seed_value)], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
exceptExceptionase:
print("An exception occurred:", str(e))
returnstr(e)
returnret
ifrequest.method=='GET':
returnsocket.gethostname()
if__name__=='__main__':
app.run(host='0.0.0.0', port=5000, threaded=True)