Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion earthreader/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from six.moves import urllib

from flask import Flask, jsonify, render_template, request, url_for
from libearth import version
from libearth.codecs import Rfc3339
from libearth.compat import text_type
from libearth.crawler import crawl
Expand Down Expand Up @@ -166,7 +167,10 @@ def add_feed(category_id):
cursor = Cursor(category_id)
url = request.form['url']
try:
f = urllib.request.urlopen(url)
rq = urllib.request.Request(url)
rq.add_header('User-Agent', '{0}/{1}'.format(version.__package__,
version.VERSION))
f = urllib.request.urlopen(rq):
document = f.read()
f.close()
except Exception:
Expand Down
4 changes: 2 additions & 2 deletions earthreader/web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ <h1>Earth Reader</h1>
<li class="fold">
<div class="form">
<h2>Add Feed</h2>
<form action="/feeds/" class="addFeed" data-after="makeFeedList">
<form action="{{ url_for('.feeds', method='POST') }}" class="addFeed" data-after="makeFeedList">
<input type="url" name="url" placeholder="URL"/>
<input type="submit" value="Add"/>
</form>
</div>
<div class="form">
<h2>Add Category</h2>
<form action="/" class="addCategory" data-after="makeFeedList">
<form action="{{ url_for('.add_category', method='POST') }}" class="addCategory" data-after="makeFeedList">
<input type="text" name="title" placeholder="title"/>
<input type="submit" value="Add"/>
</form>
Expand Down