ssh_key.py 1.2 KB

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