안녕 난이플라스크 양식 및 자바 스크립트
<form>
<input type="text" id="filepathz" size="40" placeholder="Spot your project files">
<input type="button" id="spotButton" value="Spot">
</form>
아래의 HTML 코드 자바 스크립트 코드
window.onload = init;
function init() {
var button = document.getElementById("spotButton");
button.onclick = handleButtonClick;
}
function handleButtonClick(e) {
var filepathz = document.getElementById("filepathz");
var path = filepathz.value;
if (path == "") {
alert("give a filepath");
}else{
var url = "http://localhost:5000/tx/checkme/filepathz=" + path;
window.open (url,'_self',false);
}
}
와 플라스크에 파이썬 코드 내가 뭘 잘못
def index():
"""Load start page where you select your project folder
or load history projects from local db"""
from txclib import get_version
txc_version = get_version()
prj = project.Project(path_to_tx)
# Let's create a resource list from our config file
res_list = []
prev_proj = ''
for idx, res in enumerate(prj.get_resource_list()):
hostname = prj.get_resource_host(res)
username, password = prj.getset_host_credentials(hostname)
return render_template('init.html', txc_version=txc_version, username=username)
@app.route('/tx/checkme/<filepathz>')
def checkme(filepathz):
filepathz = request.args.get('filepathz')
return render_template('init.html', txc_version=filepathz)
및 양식에서 데이터를 가져올 수 없습니다 (filepathz) < --- 나는 아무 것도 얻지 못합니다
당신은 당신의 이벤트가 트리거 확인 할 수 있습니까? (console.log 포함)? 그 filepathz 변수가 onclick 이벤트 내에서 정의되지 않았습니까? –
아니요. 자바 스크립트 부분이 잘 작동합니다. 또한 http : // localhost : 5000/tx/checkme/filepathz = "USERS INPUT"이라는 새 링크를 열지 만 파이썬에 전달하지는 않습니다! –