-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage_share.py
More file actions
18 lines (14 loc) · 771 Bytes
/
page_share.py
File metadata and controls
18 lines (14 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from flask import Blueprint, render_template, request
from .page_respond import get_poll, render_error
from . import config
bp = Blueprint("share", __name__, url_prefix = "/share")
@bp.route("/")
def index():
poll = get_poll()
if not poll:
return render_error("The poll you were shared was not found.", True)
# Do it this way instead of using url_for in the jinja template because we want the generated
# QR code iamge to have the correct domain that is accessible by the end user scanning it
protocol, port = request.host_url.split(":")[0], request.host.split(":")[1]
base_url = protocol + "://" + config.settings["base_domain"] + ":" + port + "/respond/vote?id="
return render_template("share.html", base = base_url, poll = poll)