Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用html和cheeypy将对象放入隐藏的输入字段 下面是abc.html 文件名 虚拟文件名 下面是python函数 @樱桃树 def可以恢复mds(自我、*args、**kwargs): 恢复数据={ “abc”:“def”, “akjshd”:“asd”, 'is_valid':1, } 还原上下文={ “page”:“abc.html”, “restoreData”:restoreData, } html=呈现页面(还原上下文,还原上下文['page'])) 返回{ “html”:html, “restoreData”:restoreData, } 返回响应_Python_Html_Cherrypy - Fatal编程技术网

如何使用html和cheeypy将对象放入隐藏的输入字段 下面是abc.html 文件名 虚拟文件名 下面是python函数 @樱桃树 def可以恢复mds(自我、*args、**kwargs): 恢复数据={ “abc”:“def”, “akjshd”:“asd”, 'is_valid':1, } 还原上下文={ “page”:“abc.html”, “restoreData”:restoreData, } html=呈现页面(还原上下文,还原上下文['page'])) 返回{ “html”:html, “restoreData”:restoreData, } 返回响应

如何使用html和cheeypy将对象放入隐藏的输入字段 下面是abc.html 文件名 虚拟文件名 下面是python函数 @樱桃树 def可以恢复mds(自我、*args、**kwargs): 恢复数据={ “abc”:“def”, “akjshd”:“asd”, 'is_valid':1, } 还原上下文={ “page”:“abc.html”, “restoreData”:restoreData, } html=呈现页面(还原上下文,还原上下文['page'])) 返回{ “html”:html, “restoreData”:restoreData, } 返回响应,python,html,cherrypy,Python,Html,Cherrypy,“restoreData”是一个变量,在服务器端渲染中没有以正确的格式注入。有人可以帮助您做什么吗?您可以使用json转储函数来完成此操作:- 蟒蛇 below is abc.html <div xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:py="http://genshi.edgewall.org/" py:strip="True" > <div class="i

“restoreData”是一个变量,在服务器端渲染中没有以正确的格式注入。有人可以帮助您做什么吗?

您可以使用json转储函数来完成此操作:-

蟒蛇

    below is abc.html

    <div xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:py="http://genshi.edgewall.org/" py:strip="True" >
            <div class="insync-bluthm-tbl-wrp">
                <div class="insync-bluthm-tbl-scroll">
                    <div class="insync-bluthm-tbl-scroll-inr">
                        <table class="insync-bluthm-tbl">
                        <thead>
                            <tr>
                                <th><div>File Name</div></th>
                            </tr>
                        </thead>
                        <tbody>
                            <input type="hidden" id="restorable_data" value="${restoreData}"/>
                            <tr>
                                <td><div>Dummy File name</div></td>
                            </tr>
                        </tbody>
                    </table>
                    </div>
                </div>
            </div>
    </div>

    below is python function

    @cherrypy.expose
    def can_restore_mds(self, *args, **kwargs):
    restoreData = {
            'abc': 'def',
            'akjshd': 'asd',
            'is_valid': 1,
    }
    restore_context = {
        'page': 'abc.html',
        'restoreData': restoreData,
    }
    html = render_page(restore_context, restore_context['page'])
    return {
        'html': html,
        'restoreData': restoreData,
    }
    return response
HTML


# remember to import json in your python file
restoreData = {
    'abc': 'def',
    'akjshd': 'asd',
    'is_valid': 1,
}
restore_context = {
    'page': 'abc.html',
    'restoreData': json.dumps(restoreData),
}
<input type="hidden" id="restorable_data" value="${restoreData}"/>