右对齐大熊猫数据框中的烧瓶中



我正在用烧瓶创建API。我想在"上传"按钮对面显示PANDAS DATAFRAME。我可以通过各种方法来搜索列标题/文本的合理性,但不能使用框架本身。使用的烧瓶代码是:

app = Flask(__name__)
@app.route('/upload', endpoint='upload_file1')
def upload_file1():
    df_table=data.head().to_html()   
    return render_template('upload.html', df_table=df_table)

html代码是:

<html>
<head>       
<title>CR prediction tool</title> 
</head> 
    <body bgcolor="#E6E6FA">

      <form action = "http://localhost:5000/uploader" method = "POST" 
         enctype = "multipart/form-data" >
         <input type = "file" name = "file"  />
         <input type = "submit" />
         {% block content %}
         <style  align= "float:right">
         </style>   
         {{df_table | safe}}
         {% endblock %} 

有很多方法可以使html元素像这样。这是一种简单的方法。将这两个元素包装在自己的div中,然后使用CSS将DIV设置为display: inline-block,然后给出固定或百分比的width。让我知道这是否有帮助。有关工作示例,请检查此jsfiddle:https://jsfiddle.net/35fy20ls/4/

<style>
    .inline-block {
        display: inline-block;
        width: 40%;
    }
</style>
<div class="inline-block">
    <form action = "http://localhost:5000/uploader" method = "POST" enctype = "multipart/form-data" >
        <input type = "file" name = "file"  />
        <input type = "submit" />
    </form>
</div>
<div class="inline-block">
    {% block content %}
    {{df_table | safe}}
    {% endblock %} 
</div>

最新更新