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.
 
 
 
 

35 lines
884 B

from flask import (
request,
jsonify,
current_app,
render_template,
Blueprint
)
from .npc_party import create_party
from .models import Spell
npc_views = Blueprint(
'npc_views',
__name__,
template_folder='templates',
url_prefix='/npc'
)
@npc_views.route('/party')
@npc_views.route('/party/<int:base_level>')
def generate_npc_party(base_level=None):
party = None
if base_level:
party = create_party(base_level)
# If asked for JSON, return the party, otherwise render HTML template
if request.args.get('format', 'html') == 'json':
return jsonify([npc.roll20_format for npc in party])
return render_template('generate_npc_party.html', party=party, base_level=base_level)
@npc_views.route('/spells')
def spell_list():
spells = Spell.query.all()
return render_template('spell_list.html', spells=spells)