misc.py 938 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from flask import Blueprint, render_template, request
  5. import requests
  6. __author__ = 'James Iter'
  7. __date__ = '2017/9/12'
  8. __contact__ = 'james.iter.cn@gmail.com'
  9. __copyright__ = '(c) 2017 by James Iter.'
  10. blueprint = Blueprint(
  11. 'v_misc',
  12. __name__,
  13. url_prefix='/'
  14. )
  15. def login():
  16. host_url = request.host_url.rstrip('/')
  17. if request.method == 'POST':
  18. payload = {
  19. 'login_name': request.form.get('login_name'),
  20. 'password': request.form.get('password')
  21. }
  22. url = host_url + '/api/user/_sign_in'
  23. headers = {'content-type': 'application/json'}
  24. ret = requests.post(url, data=json.dumps(payload), headers=headers)
  25. ret = json.loads(ret.content)
  26. if ret['state']['code'] == '200':
  27. return
  28. else:
  29. pass
  30. else:
  31. return render_template('login.html')