Created
April 14, 2016 23:51
-
-
Save monkeybutter/615b7974b40d9ffa2273b096d253d62b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, make_response | |
import matplotlib.pyplot as plt | |
import StringIO | |
import numpy as np | |
app = Flask(__name__) | |
@app.route('/plots/<f>') | |
def show_user_profile(f): | |
f = int(f) | |
x= np.linspace(0,1,100) | |
y= np.sin(2*np.pi*x*f) | |
fig = plt.figure() | |
plt.plot(x, y) | |
output = StringIO.StringIO() | |
fig.savefig(output) | |
response = make_response(output.getvalue()) | |
response.mimetype = 'image/png' | |
return response | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=8888) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment