Skip to content

Instantly share code, notes, and snippets.

View aliraza-io's full-sized avatar

Ali Raza aliraza-io

  • Faisalabad, Punjab, Pakistan
View GitHub Profile
@aliraza-io
aliraza-io / app.py
Created June 26, 2018 05:43 — forked from rduplain/app.py
Plot a PNG using matplotlib in a web request, using Flask.
"Plot a PNG using matplotlib in a web request, using Flask."
# Install dependencies, preferably in a virtualenv:
#
# pip install flask matplotlib
#
# Run the development server:
#
# python app.py
#
@aliraza-io
aliraza-io / flaskplotlib.py
Created June 26, 2018 05:43 — forked from wilsaj/flaskplotlib.py
Example of rendering a matplotlib image directly to Flask view
from flask import Flask, make_response
app = Flask(__name__)
@app.route("/simple.png")
def simple():
import datetime
import StringIO
import random
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas