☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Simple example of integrating a bokeh plot into a flask app

Community Support
Geoffrey_Stoel
Geoffrey_Stoel

Hi there,

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

⌁   Link to post
Sarah_Bird3
Sarah_Bird3

I would imagine something like this:

@app.route(‘/plot/’

    )

@app.route(‘/plot/’)

def hello(color=‘red’):
plot = make_my_plot(color)
script, div = embed.components(plot)
return render_template(
‘bokeh.html’,
script=script,
div=div,
)

template something like this

Bokeh Plot
    <link rel="stylesheet" href="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css)" type="text/css" />
    <script type="text/javascript" src="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js)"></script>

{{ div | safe }}

{{ script | safe }}

···

On Fri, Jul 17, 2015 at 9:26 PM, Geoffrey Stoel g.stoel@hourglazz.com wrote:

Hi there,

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7cbb387b-d4d6-4ab5-8959-415050629450%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post
Sarah_Bird3
Sarah_Bird3

if it wasn’t clear it’s

flask’s render_template function
and
bokeh.embed components function

···

On Fri, Jul 17, 2015 at 10:02 PM, Sarah Bird sbird@alum.mit.edu wrote:

I would imagine something like this:

@app.route(‘/plot/’

    )

@app.route(‘/plot/’)

def hello(color=‘red’):
plot = make_my_plot(color)
script, div = embed.components(plot)
return render_template(
‘bokeh.html’,
script=script,
div=div,
)

template something like this

Bokeh Plot
    <link rel="stylesheet" href="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css)" type="text/css" />
    <script type="text/javascript" src="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js)"></script>

{{ div | safe }}

{{ script | safe }}

On Fri, Jul 17, 2015 at 9:26 PM, Geoffrey Stoel g.stoel@hourglazz.com wrote:

Hi there,

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7cbb387b-d4d6-4ab5-8959-415050629450%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post
Geoffrey_Stoel
Geoffrey_Stoel

Thanks Sarah…

really helpful… and it works… I updated my scripts with it and pushed it back onto my github…

I will write a small tutorial on this with a bit more elaborate code example in the coming week or so… I really have been looking for a simple integrated example between flask and bokeh and couldn’t find it before… will get back to the mailing list when I put it out there…

Rgds,

Geoffrey

···

On Friday, July 17, 2015 at 10:04:26 PM UTC+2, Sarah Bird wrote:

if it wasn’t clear it’s

flask’s render_template function
and
bokeh.embed components function

On Fri, Jul 17, 2015 at 10:02 PM, Sarah Bird sb...@alum.mit.edu wrote:

I would imagine something like this:

@app.route(‘/plot/’

    )

@app.route(‘/plot/’)

def hello(color=‘red’):
plot = make_my_plot(color)
script, div = embed.components(plot)
return render_template(
‘bokeh.html’,
script=script,
div=div,
)

template something like this

Bokeh Plot
    <link rel="stylesheet" href="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css)" type="text/css" />
    <script type="text/javascript" src="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js)"></script>

{{ div | safe }}

{{ script | safe }}

On Fri, Jul 17, 2015 at 9:26 PM, Geoffrey Stoel g.s...@hourglazz.com wrote:

Hi there,

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7cbb387b-d4d6-4ab5-8959-415050629450%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post
Fabio_Pliger
Fabio_Pliger

Hi Geoffrey,

···

On Fri, Jul 17, 2015 at 10:27 PM, Geoffrey Stoel g.stoel@hourglazz.com wrote:

Thanks Sarah…

really helpful… and it works… I updated my scripts with it and pushed it back onto my github…

I will write a small tutorial on this with a bit more elaborate code example in the coming week or so…

That’d be awesome!

I really have been looking for a simple integrated example between flask and bokeh and couldn’t find it before… will get back to the mailing list when I put it out there…

FYI, I plan to add at least a couple of significant examples showing this by around next week.

Best

Fabio

Rgds,

Geoffrey

On Friday, July 17, 2015 at 10:04:26 PM UTC+2, Sarah Bird wrote:

if it wasn’t clear it’s

flask’s render_template function
and
bokeh.embed components function

On Fri, Jul 17, 2015 at 10:02 PM, Sarah Bird sb...@alum.mit.edu wrote:

I would imagine something like this:

@app.route(‘/plot/’

    )

@app.route(‘/plot/’)

def hello(color=‘red’):
plot = make_my_plot(color)
script, div = embed.components(plot)
return render_template(
‘bokeh.html’,
script=script,
div=div,
)

template something like this

Bokeh Plot
    <link rel="stylesheet" href="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css)" type="text/css" />
    <script type="text/javascript" src="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js)"></script>

{{ div | safe }}

{{ script | safe }}

On Fri, Jul 17, 2015 at 9:26 PM, Geoffrey Stoel g.s...@hourglazz.com wrote:

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

Hi there,

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7cbb387b-d4d6-4ab5-8959-415050629450%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/090e20fd-4bc0-4f40-b5b8-9cc6fed70e76%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–

Fabio Pliger

⌁   Link to post
Geoffrey_Stoel
Geoffrey_Stoel

Fabio,

is there a place where I could contribute my little tutorial? Documentation or so?

···

On Fri, Jul 17, 2015 at 11:10 PM, Fabio Pliger fabio.pliger@continuum.io wrote:

Hi Geoffrey,

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAPVmnqCwvHMHW%3D6TEnY19BWe%3D%2BXbprTW8A0Fdd23eNVt112AgA%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

On Fri, Jul 17, 2015 at 10:27 PM, Geoffrey Stoel g.stoel@hourglazz.com wrote:

Thanks Sarah…

really helpful… and it works… I updated my scripts with it and pushed it back onto my github…

I will write a small tutorial on this with a bit more elaborate code example in the coming week or so…

That’d be awesome!

I really have been looking for a simple integrated example between flask and bokeh and couldn’t find it before… will get back to the mailing list when I put it out there…

FYI, I plan to add at least a couple of significant examples showing this by around next week.

Best

Fabio

Rgds,

Geoffrey

On Friday, July 17, 2015 at 10:04:26 PM UTC+2, Sarah Bird wrote:

if it wasn’t clear it’s

flask’s render_template function
and
bokeh.embed components function

On Fri, Jul 17, 2015 at 10:02 PM, Sarah Bird sb...@alum.mit.edu wrote:

I would imagine something like this:

@app.route(‘/plot/’

    )

@app.route(‘/plot/’)

def hello(color=‘red’):
plot = make_my_plot(color)
script, div = embed.components(plot)
return render_template(
‘bokeh.html’,
script=script,
div=div,
)

template something like this

Bokeh Plot
    <link rel="stylesheet" href="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css)" type="text/css" />
    <script type="text/javascript" src="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js)"></script>

{{ div | safe }}

{{ script | safe }}

On Fri, Jul 17, 2015 at 9:26 PM, Geoffrey Stoel g.s...@hourglazz.com wrote:

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

Hi there,

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7cbb387b-d4d6-4ab5-8959-415050629450%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/090e20fd-4bc0-4f40-b5b8-9cc6fed70e76%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–
Fabio Pliger

⌁   Link to post
Fabio_Pliger
Fabio_Pliger

Geoffrey,

It depends a lot on the content itself… I’d suggest to put down the concept first so we can better understand where/how to integrate it. Does it make sense?

Fabio

···

On Fri, Jul 17, 2015 at 11:12 PM, Geoffrey Stoel g.stoel@hourglazz.com wrote:

Fabio,

is there a place where I could contribute my little tutorial? Documentation or so?

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAGMoxQaVrEE5M%3DS%2B2H1pnURBn%2BVzvjg0zyvO1Lkt85m1c%2B8XRA%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–

On Fri, Jul 17, 2015 at 11:10 PM, Fabio Pliger fabio.pliger@continuum.io wrote:

Hi Geoffrey,

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAPVmnqCwvHMHW%3D6TEnY19BWe%3D%2BXbprTW8A0Fdd23eNVt112AgA%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

On Fri, Jul 17, 2015 at 10:27 PM, Geoffrey Stoel g.stoel@hourglazz.com wrote:

Thanks Sarah…

really helpful… and it works… I updated my scripts with it and pushed it back onto my github…

I will write a small tutorial on this with a bit more elaborate code example in the coming week or so…

That’d be awesome!

I really have been looking for a simple integrated example between flask and bokeh and couldn’t find it before… will get back to the mailing list when I put it out there…

FYI, I plan to add at least a couple of significant examples showing this by around next week.

Best

Fabio

Rgds,

Geoffrey

On Friday, July 17, 2015 at 10:04:26 PM UTC+2, Sarah Bird wrote:

if it wasn’t clear it’s

flask’s render_template function
and
bokeh.embed components function

On Fri, Jul 17, 2015 at 10:02 PM, Sarah Bird sb...@alum.mit.edu wrote:

I would imagine something like this:

@app.route(‘/plot/’

    )

@app.route(‘/plot/’)

def hello(color=‘red’):
plot = make_my_plot(color)
script, div = embed.components(plot)
return render_template(
‘bokeh.html’,
script=script,
div=div,
)

template something like this

Bokeh Plot
    <link rel="stylesheet" href="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css)" type="text/css" />
    <script type="text/javascript" src="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js)"></script>

{{ div | safe }}

{{ script | safe }}

On Fri, Jul 17, 2015 at 9:26 PM, Geoffrey Stoel g.s...@hourglazz.com wrote:

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

Hi there,

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7cbb387b-d4d6-4ab5-8959-415050629450%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/090e20fd-4bc0-4f40-b5b8-9cc6fed70e76%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–
Fabio Pliger

Fabio Pliger

⌁   Link to post
Sarah_Bird3
Sarah_Bird3

Glad it worked Geoffrey.

I also have an example for Europython talk (which I’m giving on monday), both a simple example in my presentation (https://github.com/birdsarah/europython-2015-bokeh) and something a little more complex that I’m building up here: https://github.com/birdsarah/gtimelog-viz

(both are not quite finished yet).

Sorry that these resources weren’t quite ready for when you needed them.

···

On Sat, Jul 18, 2015 at 12:06 AM, Fabio Pliger fabio.pliger@continuum.io wrote:

Geoffrey,

It depends a lot on the content itself… I’d suggest to put down the concept first so we can better understand where/how to integrate it. Does it make sense?

Fabio

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAPVmnqCyUiHH7_AhQEPvdH1HDupXjR2ZDZuxKgz3hNay7gR4gQ%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

On Fri, Jul 17, 2015 at 11:12 PM, Geoffrey Stoel g.stoel@hourglazz.com wrote:

Fabio,

is there a place where I could contribute my little tutorial? Documentation or so?

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAGMoxQaVrEE5M%3DS%2B2H1pnURBn%2BVzvjg0zyvO1Lkt85m1c%2B8XRA%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–
Fabio Pliger

On Fri, Jul 17, 2015 at 11:10 PM, Fabio Pliger fabio.pliger@continuum.io wrote:

Hi Geoffrey,

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAPVmnqCwvHMHW%3D6TEnY19BWe%3D%2BXbprTW8A0Fdd23eNVt112AgA%40mail.gmail.com.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

On Fri, Jul 17, 2015 at 10:27 PM, Geoffrey Stoel g.stoel@hourglazz.com wrote:

Thanks Sarah…

really helpful… and it works… I updated my scripts with it and pushed it back onto my github…

I will write a small tutorial on this with a bit more elaborate code example in the coming week or so…

That’d be awesome!

I really have been looking for a simple integrated example between flask and bokeh and couldn’t find it before… will get back to the mailing list when I put it out there…

FYI, I plan to add at least a couple of significant examples showing this by around next week.

Best

Fabio

Rgds,

Geoffrey

On Friday, July 17, 2015 at 10:04:26 PM UTC+2, Sarah Bird wrote:

if it wasn’t clear it’s

flask’s render_template function
and
bokeh.embed components function

On Fri, Jul 17, 2015 at 10:02 PM, Sarah Bird sb...@alum.mit.edu wrote:

I would imagine something like this:

@app.route(‘/plot/’

    )

@app.route(‘/plot/’)

def hello(color=‘red’):
plot = make_my_plot(color)
script, div = embed.components(plot)
return render_template(
‘bokeh.html’,
script=script,
div=div,
)

template something like this

Bokeh Plot
    <link rel="stylesheet" href="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css)" type="text/css" />
    <script type="text/javascript" src="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js)"></script>

{{ div | safe }}

{{ script | safe }}

On Fri, Jul 17, 2015 at 9:26 PM, Geoffrey Stoel g.s...@hourglazz.com wrote:

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

Hi there,

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7cbb387b-d4d6-4ab5-8959-415050629450%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/090e20fd-4bc0-4f40-b5b8-9cc6fed70e76%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

–
Fabio Pliger

⌁   Link to post
sayanti.banerjee
sayanti.banerjee

Hello Sarah,

I just tried your suggestion and when I run the python script it doesn’t render the plot. Just the options to select if I want the plot in green, red, or blue. Any idea as to what I might be missing here?

Thanks so much!

Sayanti

···

On Friday, July 17, 2015 at 1:03:08 PM UTC-7, Sarah Bird wrote:

I would imagine something like this:

@app.route(‘/plot/’

    )

@app.route(‘/plot/’)

def hello(color=‘red’):
plot = make_my_plot(color)
script, div = embed.components(plot)
return render_template(
‘bokeh.html’,
script=script,
div=div,
)

template something like this

Bokeh Plot
    <link rel="stylesheet" href="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css)" type="text/css" />
    <script type="text/javascript" src="[http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js](http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js)"></script>

{{ div | safe }}

{{ script | safe }}

On Fri, Jul 17, 2015 at 9:26 PM, Geoffrey Stoel g.s...@hourglazz.com wrote:

Hi there,

I asked this question on twitter before and Bryan asked me to put it onto the mailing list, so here it comes.

I’d like to get a very basic and simple example to work on how to embed a bokeh plot into a flask web app.

I created a very basic structure in my git: https://github.com/gstoel/bokeh_flask_example

I would like to achieve two goals:

  1. get the bokeh plot integrated in my http://localhost:5000/plot/
  2. being able to change the color based on the attribute I give in the url http://localhost:5000/plot/green for example

I have seen examples that write out to html file and then read in the html, strip out the non tags and merge it into the template, but that doesn’t sound like a viable (and maintainable) solution to me.

Also I’d rather not spin up a bokeh-server for this, to keep everything simple and easy (one application to rule them all :))

All the code is very basic and very simple, main goal is to understand the best way and minimal way to include the bokeh plot.

Hope you guys can help me,

Tnx,

G.

–

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7cbb387b-d4d6-4ab5-8959-415050629450%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

⌁   Link to post

End of archived discussion · Replies are disabled