ssh_key.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from flask import Blueprint, url_for, request, redirect
  5. import requests
  6. from . import render
  7. __author__ = 'James Iter'
  8. __date__ = '2018/2/27'
  9. __contact__ = 'james.iter.cn@gmail.com'
  10. __copyright__ = '(c) 2018 by James Iter.'
  11. blueprint = Blueprint(
  12. 'v_ssh_key',
  13. __name__,
  14. url_prefix='/ssh_key'
  15. )
  16. blueprints = Blueprint(
  17. 'v_ssh_keys',
  18. __name__,
  19. url_prefix='/ssh_keys'
  20. )
  21. def show():
  22. url = url_for('api_ssh_keys.r_show', _external=True)
  23. if request.args.__len__() >= 1:
  24. args = list()
  25. for k, v in request.args.items():
  26. args.append('='.join([k, v]))
  27. url += '?' + '&'.join(args)
  28. ret = requests.get(url=url, cookies=request.cookies)
  29. ret = json.loads(ret.content)
  30. return render('ssh_keys_show.html', ssh_keys=ret['data']['ssh_keys'], paging=ret['data']['paging'],
  31. page=ret['data']['page'], page_size=ret['data']['page_size'], keyword=ret['data']['keyword'],
  32. pages=ret['data']['pages'], order_by=ret['data']['order_by'], order=ret['data']['order'],
  33. last_page=ret['data']['last_page'])
  34. def create():
  35. return redirect(url_for('v_ssh_keys.show'))