途中で少し混乱してしまいました、助けていただければ幸いです。
以下のようなテキストファイルがあります。
./Video/SetUp
./Video/NewRecordings
./Video/NewRecordings/20160113_151920
./Video/Back Up
./Video/Back Up/FirstLecDraft
./Video/Back Up/FirstTalk
以下の python スクリプトを使用して ( Dominateのおかげで)、List上記のテキスト ファイルを使用して html ファイルを作成します。
import dominate
from dominate.tags import *
doc = dominate.document(title='Dominate your HTML')
with doc.head:
link(rel='stylesheet', href='style.css')
script(type='text/javascript', src='script.js')
with doc:
with div():
with open('List') as f:
for line in f:
li(input(line.title(), type='submit', value='%s' % line, onclick='self.location.href=\'http://127.0.0.1:5000/{This must be the same as "value" part}\''))
with div():
attr(cls='body')
print doc
最初の質問:valueフィールドの値をパスの残りの部分に渡す方法はonclick?
結果は次のようになります。
<input href="" onclick="self.location.href='http://127.0.0.1:5000/cameradump/2016-01-21" type="submit" value="./cameradump/2016-01-21">
およびそれぞれ別のボタンの別の値。
ご覧のとおり、onclick パスの残りの部分は、フィールド:5000/とまったく同じでなければなりません。value
main.py2 番目の質問: これをフラスコのファイルのルートに渡すにはどうすればよいですか? (たとえば、ユーザーが各ボタンを押したときに、そのボタンの値をルートに動的に設定する必要があります)
main.py今のところ次のようになります。
from flask import Flask, render_template
import subprocess
app = Flask(__name__)
@app.route("/{value must be passed here}")
def index():
return render_template('index.html')
...
ただし、ユーザーがボタンを押すと、次のようになります/cameradump/2016-01-21。
...
@app.route("/cameradump/2016-01-21")
def index():
return render_template('index.html')
...
または押されたボタンに応じた別の値。