Compare commits
2 commits
be4db13179
...
8901831568
Author | SHA1 | Date | |
---|---|---|---|
Edward Betts | 8901831568 | ||
Edward Betts | b6cc79291b |
12
web_view.py
12
web_view.py
|
@ -146,6 +146,8 @@ def start_oauth() -> Response:
|
|||
flask.session["owner_key"] = fetch_response.get("oauth_token")
|
||||
flask.session["owner_secret"] = fetch_response.get("oauth_token_secret")
|
||||
|
||||
assert flask.session["owner_key"] and flask.session["owner_secret"]
|
||||
|
||||
base_authorization_url = f"https://{wiki_hostname}/wiki/Special:OAuth/authorize"
|
||||
authorization_url = oauth.authorization_url(
|
||||
base_authorization_url, oauth_consumer_key=client_key
|
||||
|
@ -162,8 +164,8 @@ def oauth_callback() -> werkzeug.wrappers.response.Response:
|
|||
oauth = OAuth1Session(
|
||||
client_key,
|
||||
client_secret=client_secret,
|
||||
resource_owner_key=flask.session["owner_key"],
|
||||
resource_owner_secret=flask.session["owner_secret"],
|
||||
resource_owner_key=flask.session.get("owner_key"),
|
||||
resource_owner_secret=flask.session.get("owner_secret"),
|
||||
)
|
||||
|
||||
oauth_response = oauth.parse_authorization_response(flask.request.url)
|
||||
|
@ -257,7 +259,7 @@ def get_best_hit(title: str, hits: list[Hit]) -> tuple[Hit, dict[str, typing.Any
|
|||
raise NoGoodHit
|
||||
|
||||
|
||||
@app.route("/<path:url_title>", methods=["GET", "POST"])
|
||||
@app.route("/link/<path:url_title>", methods=["GET", "POST"])
|
||||
def article_page(url_title: str) -> str | Response:
|
||||
"""Article page."""
|
||||
from_title = url_title.replace("_", " ").strip()
|
||||
|
@ -343,8 +345,8 @@ def api_hits() -> werkzeug.wrappers.response.Response:
|
|||
@app.route("/api/1/valid_hit")
|
||||
def api_valid_hit() -> werkzeug.wrappers.response.Response:
|
||||
"""Return canidates for the given article title."""
|
||||
link_from = flask.request.args.get("link_from")
|
||||
link_to = flask.request.args.get("link_to")
|
||||
link_from = flask.request.args["link_from"]
|
||||
link_to = flask.request.args["link_to"]
|
||||
|
||||
try:
|
||||
diff, replacement = get_diff(link_to, link_from, None)
|
||||
|
|
Loading…
Reference in a new issue