Stop using python keyword id for id
This commit is contained in:
		| @@ -36,9 +36,9 @@ def update(story): | |||||||
|             ) |             ) | ||||||
|     writer.commit() |     writer.commit() | ||||||
|  |  | ||||||
| def get_story(id): | def get_story(sid): | ||||||
|     with ix.searcher() as searcher: |     with ix.searcher() as searcher: | ||||||
|         result = searcher.document(id=id) |         result = searcher.document(id=sid) | ||||||
|         return result['story'] if result else None |         return result['story'] if result else None | ||||||
|  |  | ||||||
| def search(search): | def search(search): | ||||||
|   | |||||||
| @@ -30,11 +30,11 @@ with shelve.open(DATA_FILE) as db: | |||||||
|     news_ref_to_id = db.get('news_ref_to_id', {}) |     news_ref_to_id = db.get('news_ref_to_id', {}) | ||||||
|     news_cache = db.get('news_cache', {}) |     news_cache = db.get('news_cache', {}) | ||||||
|  |  | ||||||
| def get_story(id): | def get_story(sid): | ||||||
|     if id in news_cache: |     if sid in news_cache: | ||||||
|         return news_cache[id] |         return news_cache[sid] | ||||||
|     else: |     else: | ||||||
|         return archive.get_story(id) |         return archive.get_story(sid) | ||||||
|  |  | ||||||
| build_folder = '../webclient/build' | build_folder = '../webclient/build' | ||||||
| flask_app = Flask(__name__, template_folder=build_folder, static_folder=build_folder, static_url_path='') | flask_app = Flask(__name__, template_folder=build_folder, static_folder=build_folder, static_url_path='') | ||||||
| @@ -60,27 +60,28 @@ def search(): | |||||||
|         res = [] |         res = [] | ||||||
|     return {'results': res} |     return {'results': res} | ||||||
|  |  | ||||||
| @flask_app.route('/api/<id>') | @flask_app.route('/api/<sid>') | ||||||
| def story(id): | def story(sid): | ||||||
|     story = get_story(id) |     story = get_story(sid) | ||||||
|     return dict(story=story) if story else abort(404) |     return dict(story=story) if story else abort(404) | ||||||
|  |  | ||||||
| @flask_app.route('/') | @flask_app.route('/') | ||||||
|  | @flask_app.route('/search') | ||||||
| def index(): | def index(): | ||||||
|     return render_template('index.html', |     return render_template('index.html', | ||||||
|             title='Feed', |             title='Feed', | ||||||
|             url='news.t0.vc', |             url='news.t0.vc', | ||||||
|             description='Reddit, Hacker News, and Tildes combined, then pre-rendered in reader mode') |             description='Reddit, Hacker News, and Tildes combined, then pre-rendered in reader mode') | ||||||
|  |  | ||||||
| @flask_app.route('/<id>', strict_slashes=False) | @flask_app.route('/<sid>', strict_slashes=False) | ||||||
| @flask_app.route('/<id>/c', strict_slashes=False) | @flask_app.route('/<sid>/c', strict_slashes=False) | ||||||
| def static_story(id): | def static_story(sid): | ||||||
|     try: |     try: | ||||||
|         return flask_app.send_static_file(id) |         return flask_app.send_static_file(sid) | ||||||
|     except NotFound: |     except NotFound: | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     story = get_story(id) |     story = get_story(sid) | ||||||
|     if not story: return abort(404) |     if not story: return abort(404) | ||||||
|  |  | ||||||
|     score = story['score'] |     score = story['score'] | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user