我正在使用Flask和Python。对于一条路线,我正在做以下
@app.route('/volumes/<volumeid>')
def volumeSpecific(volumeid):
if volumeid not in volumesList:
abort(404)
else:
import retrieveVolumes
return render_template('index.html')
问题是,在我的retrieveVolumes
文件中,我需要特定的volumeid
参数。
在retrieveVolumes
文件中,这是我使用它的地方
current_snapshots = conn.get_all_snapshots(filters={'volume-id': volumeId})
我尝试为参数volumeid
创建一个全局变量,但这不起作用。
如何将参数传递给其他文件?
答案 0 :(得分:0)
模块不能用作函数。至少在retrieveVolumes模块中添加main
函数,然后您可以使用main(volumeId=volumeId)
或类似函数调用它。