Skip to content

Commit

Permalink
Flat bl file
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Kejval committed Jun 14, 2019
1 parent 04e3ff7 commit 39fd8d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions blacklist/views/download/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,20 @@ def generate():
mimetype="text/plain",
headers={"Content-disposition":
"attachment; filename=hosts"})

@download_index.route('/flatbl', methods=['GET'])
def get_flatbl():
items = Blacklist.query.yield_per(1000)

def generate():
for item in items:
if item.a:
yield "{}\n{}\n".format(item.a, item.dns)
if item.aaaa:
yield "{}\n{}\n".format(item.a, item.dns)

return flask.Response(
flask.stream_with_context(generate()),
mimetype="text/plain",
headers={"Content-disposition":
"attachment; filename=flatbl.txt"})
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ <h1>{{ _('Downloads') }}</h1>
<th scope="row">Unblocking hosts file</th>
<td><a href="{{url_for('download.index.get_hosts')}}" class="btn btn-primary"><i class="fa fa-download"></i> Download</a></td>
</tr>
<tr>
<th scope="row">Flat blacklist file</th>
<td><a href="{{url_for('download.index.get_flatbl')}}" class="btn btn-primary"><i class="fa fa-download"></i> Download</a></td>
</tr>
</tbody>
</table>
{% endblock %}

0 comments on commit 39fd8d3

Please sign in to comment.