在页面显示html文件,在HTML页面上按原样显示文件

我在我的项目中使用webpy框架。我想从我的webpy程序传递一个文件,并按原样显示在html页面上(文件可以是任何文本文件/程序文件)。我从webpy程序中使用以下函数传递了一个文本文件。在class display_files:

def GET(self):

wp=web.input()

file_name=wp.name

repo_name=wp.repo

repo_path=os.path.join('repos',repo_name)

file_path=os.path.join(repo_path,file_name)

fp=open(file_path,'rU') #reading file from file path

text=fp.read() #no problem found till this line.

fp.close()

return render.file_display(text) #calling file_display.html

当我试图从“file”显示文件(这里是“text”)时_显示.html'时,它连续显示而不识别换行。这里是我的html文件。在

^{pr2}$

如何显示文件在html页面中的原样。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值