add downloading challenge link

master
lza_menace 2 years ago
parent 9dc6d7761c
commit e502c1eb5d

@ -1,5 +1,7 @@
from flask import Blueprint, render_template from datetime import datetime
from flask import flash, redirect, url_for
from flask import Blueprint, render_template, request
from flask import flash, redirect, url_for, Response
from flask_login import logout_user, current_user from flask_login import logout_user, current_user
from nerochan.forms import UserForm, UserRegistration, UserChallenge from nerochan.forms import UserForm, UserRegistration, UserChallenge
@ -67,6 +69,14 @@ def challenge(handle):
flash('Already logged in.') flash('Already logged in.')
return redirect(url_for('main.index')) return redirect(url_for('main.index'))
if request.args.get('download'):
fn = int(datetime.utcnow().timestamp())
return Response(
user.challenge,
mimetype='text/plain',
headers={'Content-Disposition': f'attachment;filename=challenge_{fn}.txt'}
)
if form.validate_on_submit(): if form.validate_on_submit():
data = { data = {
'data': user.challenge, 'data': user.challenge,

@ -6,7 +6,7 @@
<div class="row"> <div class="row">
<h1>challenge</h1> <h1>challenge</h1>
<p>Handle: {{ user.handle }}</p> <p>Handle: {{ user.handle }}</p>
<p>Challenge: <span class="walletAddress">{{ user.challenge }}</span></p> <p>Challenge: <span class="walletAddress">{{ user.challenge }}</span> (<a href="?download=1" style="text-decoration-style: dashed;">download</a>)</p>
<p>Wallet Address: <span class="walletAddress">{{ user.wallet_address }}</span></p> <p>Wallet Address: <span class="walletAddress">{{ user.wallet_address }}</span></p>
{% include 'includes/form.html' %} {% include 'includes/form.html' %}
</div> </div>

Loading…
Cancel
Save