You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.9 KiB

import requests
from lxml import html
from flask import current_app, Blueprint, render_template, url_for, redirect
default_views = Blueprint('default_views', __name__, url_prefix='/')
def index():
return render_template('index.html')
def handbook():
return render_template('handbook.html')
def worldmap():
return render_template('worldmap.html')
def treasure(treasure_type=None):
# Unused, we can't tap into Autarch's generator, so just link to a new tab
# in navigation bar now
if treasure_type is not None:
with requests.Session() as s:
import pudb;pu.db
# First grab the page to pull a fresh form_build_id
treasure_page = s.get('')
dom_tree = html.fromstring(treasure_page.content)
form_build_id = dom_tree.find('.//input[@name="form_build_id"]').attrib['value']
# Use that form_build_id to make a request for generated treasure
headers = {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}
payload = {
"form_id": "acks_treasure_form",
"form_build_id": form_build_id,
"treasure_type": treasure_type
response ="", data=payload, headers=headers)
print("TG Response: {}, Payload: {}".format(response.text, payload))
generated_treasure = response.json()[1]["data"].replace('class="form-textarea"', 'class="uk-textarea"')
return render_template('treasure.html', generated_treasure=generated_treasure, treasure_type=treasure_type)
return render_template('treasure.html')