Skip to content

Instantly share code, notes, and snippets.

@monkeybutter
Created April 14, 2016 23:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monkeybutter/615b7974b40d9ffa2273b096d253d62b to your computer and use it in GitHub Desktop.
Save monkeybutter/615b7974b40d9ffa2273b096d253d62b to your computer and use it in GitHub Desktop.
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