-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished #12. All of the original project structure has been refactor…
…ed to use Blueprints. All of the original routes.py are now split into the varying categories of Blueprint subdirectories.
- Loading branch information
DeepBlockDeepak
committed
Nov 24, 2023
1 parent
519f5e7
commit 5e76965
Showing
19 changed files
with
350 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from flask import Blueprint | ||
|
||
places = Blueprint("places", __name__) | ||
|
||
from . import routes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import json | ||
from flask import render_template | ||
from flask_login import login_required | ||
from src.models import Place | ||
from src.places import places | ||
from src.scraping_functions.wiki_places import get_main_image | ||
|
||
|
||
# Renders page detailing the Place() | ||
# used for anchoring Place items within html | ||
@places.route("/place_info/<int:place_id>", methods=["POST", "GET"]) | ||
@login_required | ||
def place_info(place_id): | ||
# get the unique place by id | ||
place = Place.query.get(place_id) | ||
|
||
try: | ||
place_wiki = json.loads(place.wiki) | ||
except json.decoder.JSONDecodeError: | ||
place_wiki = json.dumps('{"error": "wiki not availble"}') | ||
|
||
url_string = get_main_image(place.city, place.state) | ||
if not url_string: | ||
url_string = "https://en.wikipedia.org/static/images/icons/wikipedia.png" | ||
|
||
# render the place template | ||
return render_template( | ||
"place.html", | ||
place=place, | ||
wiki_content=place_wiki, | ||
url_string=url_string, | ||
) |
Oops, something went wrong.