views.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Django-Graph-Plotter 作者: askprateek 项目源码 文件源码
def index(request):
    if request.method == "GET" :
        return render_to_response('bokeh/index.html')

    elif request.method == "POST" :
        domain  = request.POST['domain'].split()
        eqn     = request.POST['equation']
        domain = range( int(domain[0]), int(domain[1]) )
        y = [ eval(eqn) for x in domain ]
        title = 'y = ' + eqn

        plot = figure(title= title , x_axis_label= 'X-Axis', y_axis_label= 'Y- Axis', plot_width =400, plot_height =400)
        plot.line(domain, y, legend= 'f(x)', line_width = 2)
        script, div = components(plot)

        return render_to_response( 'bokeh/index.html', {'script' : script , 'div' : div} )


    else:
        pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号