単純な「投票」Webページがあり、ユーザーには3列のテーブルが表示されます。各列には検索エンジンクエリの結果が含まれ、ユーザーはどの列がより良い結果をもたらすかを選択し、ボタンをクリックします。
サンプルは次のとおりです:http://jsfiddle.net/rfeGa/
次の点についてサポートが必要です。1。htmlページとpythonプログラムの間の投票を追跡するにはどうすればよいですか。2.クエリのリストをPythonファイルに保持したいのですが、その情報をWebページに渡すにはどうすればよいですか?
これが私のhtmlページです:
<!DOCTYPE html>
<html>
<head>
<title>Search Engine Comparator!</title>
</head>
<body>
% queries = ("ccny", "bmcc", "qcc");
% bingScore = googScore = yhooScore = 0;
% for q in queries:
The query is: {{ q }}
<br />
And the scores are: Bing = {{ bingScore }}, Google = {{ googScore }}, Yahoo = {{ yhooScore }}.
<hr>
<form action="/" method="post">
<table border="1" width="100%">
<tr>
<th>
<input type="submit" name="engine1" value="Engine 1 is better!" />
</th>
<th>
<input type="submit" name="engine2" value="Engine 2 is better!" />
</th>
<th>
<input type="submit" name="engine3" value="Engine 3 is better!" />
</th>
</tr>
</table>
</form>
% end
</body>
</html>
<script type="text/javascript">
</script>
これが私のPythonコードです:
from bottle import request, route, run, view
from mini_proj import *
@route('/', method=['GET', 'POST'])
@view('index.html')
def index():
return dict(parts = request.forms.sentence.split(),
show_form = request.method == 'GET');
run(host = 'localhost', port = 9988);