如何使用Python和Django将文件数据返回到浏览器?
我需要在使用Python运行浏览器的URL时返回文件数据。这是我的密码:如何使用Python和Django将文件数据返回到浏览器?,python,django,Python,Django,我需要在使用Python运行浏览器的URL时返回文件数据。这是我的密码: def createfile(request): if request.method == 'GET' and 'q' in request.GET: param = request.GET['param'] if param is not None and param != '': execfile(param) 用户何时运行http://127.0.0.
def createfile(request):
if request.method == 'GET' and 'q' in request.GET:
param = request.GET['param']
if param is not None and param != '':
execfile(param)
用户何时运行
http://127.0.0.1:8000/createfile/?param=/opt/lampp/htdocs/Nuclear_reactor/d25/nuclear_vulnerable/hello.py
在浏览器上,hello.py
文件中的内容应返回浏览器 这是服务器上的路径还是客户端计算机上的路径?允许这样的任意代码执行看起来是一个很大的安全错误。文件路径来自项目文件夹,我还需要获取远程文件。你的函数没有返回值。是否要返回param
的内容或执行该脚本的结果?出于安全原因,我将避免使用execfile
。我需要返回的文件仅包含。可能重复的