Skip to content

Commit

Permalink
PEP8 reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jeb16157 committed Feb 23, 2021
1 parent 4af3c69 commit 153d4b1
Showing 1 changed file with 42 additions and 31 deletions.
73 changes: 42 additions & 31 deletions pserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,77 @@

app = Flask(__name__)


@app.route('/runSimulation/<input1>') # This is the endpoint that the javascript code will call to run simulation on server
def runSimulation(input1):
start_time = time.time()

# Parse simulation parameters.
Param=input1.split("&") # Parameters are separated by '&' delimiter.
Param = input1.split("&") # Parameters are separated by '&' delimiter.
print(Param)
ddd_state=(Param[0]=="true")
ddd_state = (Param[0] == "true")
skip_sim = (Param[1] == "true")
sumOut = (Param[2] == "true")
logOut = (Param[3] == "true")


packet_size=int(Param[4])
rtsa=int(Param[5])
max_queue_size=int(Param[6])
ddd_mapping_delay=int(Param[7])
propagation_delay=int(Param[8])
number_of_ddd_ports=int(Param[9])
time_to_next_ddd_port=int(Param[10])
overlap_time_old_ddd=int(Param[11])
packet_size = int(Param[4])
rtsa = int(Param[5])
max_queue_size = int(Param[6])
ddd_mapping_delay = int(Param[7])
propagation_delay = int(Param[8])
number_of_ddd_ports = int(Param[9])
time_to_next_ddd_port = int(Param[10])
overlap_time_old_ddd = int(Param[11])
durationSim = float(Param[12])
numbSynAckResends = int(Param[13])
clienttoRouter=int(Param[14]);
routertoClient=int(Param[15]);
routertoReflector=int(Param[16]);
routertoNormal=int(Param[17]);
normaltoRouter=int(Param[18]);
reflectortoRouter=int(Param[19]);
attackertoReflector=int(Param[20]);
queueLimit=int(Param[21]);
attackerType = float(Param[22]);
amplification = float(Param[23]);

clienttoRouter = int(Param[14])
routertoClient = int(Param[15])
routertoReflector = int(Param[16])
routertoNormal = int(Param[17])
normaltoRouter = int(Param[18])
reflectortoRouter = int(Param[19])
attackertoReflector = int(Param[20])
queueLimit = int(Param[21])
attackerType = float(Param[22])
amplification = float(Param[23])

response = main.runSimulation(ddd_state, skip_sim, sumOut, logOut, packet_size,rtsa,max_queue_size,ddd_mapping_delay,propagation_delay,number_of_ddd_ports, time_to_next_ddd_port,overlap_time_old_ddd, durationSim, numbSynAckResends, clienttoRouter, routertoClient,routertoReflector,routertoNormal,normaltoRouter,reflectortoRouter,attackertoReflector, queueLimit, attackerType, amplification)
response = main.runSimulation(ddd_state, skip_sim, sumOut,
logOut, packet_size, rtsa,
max_queue_size, ddd_mapping_delay,
propagation_delay, number_of_ddd_ports,
time_to_next_ddd_port, overlap_time_old_ddd,
durationSim, numbSynAckResends, clienttoRouter,
routertoClient, routertoReflector, routertoNormal,
normaltoRouter, reflectortoRouter,
attackertoReflector, queueLimit, attackerType,
amplification)

print('Backend Simulation Total Elapsed Time:', time.time() - start_time, 'seconds')

# Converting response data structure into json string
return jsonify(response)


@app.route('/download/<fileName>') # This is the endpoint that the javascript code will call to run simulation on server
def download(fileName):
return send_file(fileName, as_attachment=True)


@app.route('/download2/<statement>')
def download2(statement):
filename=""
newname=""
for i in range(0,len(statement)):
filename = ""
newname = ""
for i in range(0, len(statement)):
# Search for delimiter.
if statement[i]=='&':
if(statement[i] == '&'):
# Construct file names...
filename=statement[:i]
newname=statement[i+1:]
filename = statement[:i]
newname = statement[i+1:]
break
# Things are over.
return send_file(filename,as_attachment=True,attachment_filename=newname)
return send_file(filename, as_attachment=True, attachment_filename=newname)


@app.route('/')
def index():
return render_template('temp_index.html') # This renders index.html as the starting screen
return render_template('temp_index.html') # This renders index.html as the starting screen

0 comments on commit 153d4b1

Please sign in to comment.