SOLARIS_Web_Simulation/massProxy.py

59 lines
1.2 KiB
Python
Raw Normal View History

2022-12-13 18:24:26 -05:00
#!/usr/bin/python3
import cgi, cgitb
form = cgi.FieldStorage()
AZ = form.getvalue('AZ')
A=form.getvalue('A')
Z=form.getvalue('Z')
import os, subprocess
os.chdir(r"files")
result = "";
if 'AZ' in form:
result=subprocess.run(['../Cleopatra/IsotopeShort', AZ], stdout=subprocess.PIPE).stdout.decode('utf-8')
if 'A' in form:
result=subprocess.run(['../Cleopatra/IsotopeShort', A, Z], stdout=subprocess.PIPE).stdout.decode('utf-8')
print( "Content-type:text/html\r\n\r\n")
#print("<html>")
#print("<body>")
if result != "":
pA = result.find('A:')
pZ = result.find('Z:')
p1 = result.find('Mass:')
p2 = result.find('Name:')
p2a = result.find('|')
print(int(result[pA+2:pA+5]), ",", int(result[pZ+2:pZ+5]), ",", float(result[p1+5:p1+13+5]), ",", result[p2+5: p2a])
else:
print("error");
#print("<br>" + result[p1:p1+13+5])
#p1 = result.find('Sn:')
#print("<br>" + result[p1:p1+16])
#p1 = result.find('Sp')
#print("<br>" + result[p1:p1+16])
#p1 = result.find('Sa')
#print("<br>" + result[p1:p1+16])
#print("<br>=============================")
#print("</body>")
#print("</html>")
#import plotly.express as px
#fig = px.scatter(x=range(10), y = range(10))
#fig.write_html("test.html")