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

  1. from flask import (
  2. request,
  3. jsonify,
  4. current_app,
  5. render_template,
  6. Blueprint
  7. )
  8. from .npc_party import create_party
  9. from .models import Spell
  10. npc_views = Blueprint(
  11. 'npc_views',
  12. __name__,
  13. template_folder='templates',
  14. url_prefix='/npc'
  15. )
  16. @npc_views.route('/party')
  17. @npc_views.route('/party/<int:base_level>')
  18. def generate_npc_party(base_level=None):
  19. party = None
  20. if base_level:
  21. party = create_party(base_level)
  22. # If asked for JSON, return the party, otherwise render HTML template
  23. if request.args.get('format', 'html') == 'json':
  24. return jsonify([npc.roll20_format for npc in party])
  25. return render_template('generate_npc_party.html', party=party, base_level=base_level)
  26. @npc_views.route('/spells')
  27. def spell_list():
  28. spells = Spell.query.all()
  29. return render_template('spell_list.html', spells=spells)