Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
285 views
in Technique[技术] by (71.8m points)

python - nnv diagram seems to not be rendering in flask properly?

I want to show a nnv render with flask but i want to add a top bar i have a code but it the nnv.render() seems to not be rendering properly this is what i mean i only see my topbar/header.

My code:

import io
from nnv import NNV
from flask import Flask, Response

def test():
    def top_bar():
        return """ 
               <style>
               .frame {
                 position: fixed;
                 top: 0px;
                 left: 0px;
                 right: 0px;
                 width: 100%;
                 background-color: #87CEFA;
                 color: white;
                 text-align: center;
                 
                }
                   
               .chart {
                 position: fixed;
                 text-align: left;
                 margin-top: 100px;
               }
               
               </style>
               <head>
                   <title>Tkboard</title>
               </head>
               <div class="frame">
                   <h1 style="font-size:25px"><p style="font-family:verdana">Nerual-network!</p></h1>
               </div>
               
               
             """    
    
    layersList = [
        {"title":"input", "units": 3, "color": "darkBlue"},
        {"title":"hidden
layer", "units": 3},
        {"title":"output", "units": 6,"color": "darkBlue"},
    ]


    app = Flask(__name__)
    
    
    @app.route('/')
    def index():
        output = io.BytesIO()
        NNV(layersList).render(save_to_file=output)
        return (f"""
                Response(output.getvalue(), mimetype='image/png')
                {top_bar()}
                
                """)
    
    
    app.run()
    
test()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...