I'm working locally with a python script on my mac using
python3 -m http.server --cgi
My script works. I creates a graphic and a dynamic web page and opens that web page in a new tab. What I don't like is that it leaves a blank window where the script's address is. So when I run the webpage with the form and hit submit. I get a blank page and a new page. I'd just like it to go to the new page. I'm new to python, so I'm not quite sure what I'm doing wrong. Here is my script:
#!/usr/bin/env python3
import pyromat as pm
import matplotlib.pyplot as plt
import numpy as np
import webbrowser
# Create a temperature array in steps of 10K
T = np.arange(300,2000,10)
# Get the Oxygen object
O2 = pm.get('ig.O2')
f = plt.figure(1) # Call up figure 1
f.clf() # clear it (if it already exists)
ax = f.add_subplot(111) # Create an axes object on the figure
ax.plot(T, O2.cp(T)) # Add a curve to that axes
ax.set_xlabel('Temperature (K)')
ax.set_ylabel('Specific Heat (kJ/kg/K)')
f.savefig('cp.png') # Make a file
f = open('test.html','w')
message = """<html>
<head></head>
<body><p>Graph Test</p><img src="cp.png"></body>
</html>"""
f.write(message)
f.close()
filename = 'file:///Users/pzb4/Documents/Environments/test.html'
webbrowser.open(filename,new=0,autoraise=True)
Idea is to create a form where I can change the inputs to the graph. Ideally it would just rewrite the form page so the student can keep changing the data and see how it affects the graph.