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.

29 lines
719 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. npc_views = Blueprint(
  10. 'npc_views',
  11. __name__,
  12. template_folder='templates',
  13. url_prefix='/npc'
  14. )
  15. @npc_views.route('/party')
  16. @npc_views.route('/party/<int:base_level>')
  17. def generate_npc_party(base_level=None):
  18. party = None
  19. if base_level:
  20. party = create_party(base_level)
  21. # If asked for JSON, return the party, otherwise render HTML template
  22. if request.args.get('format', 'html') == 'json':
  23. return jsonify([npc.roll20_format for npc in party])
  24. return render_template('generate_npc_party.html', party=party, base_level=base_level)