misc.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from flask import Blueprint, render_template, url_for, 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. 'jimv_edition': int(request.form.get('jimv_edition', 0))
  20. }
  21. url = host_url + '/api/config'
  22. headers = {'content-type': 'application/json'}
  23. config_ret = requests.post(url, data=json.dumps(payload), headers=headers)
  24. config_ret = json.loads(config_ret.content)
  25. return render_template('success.html', go_back_url='/', timeout=5000, title='提交成功',
  26. message_title='初始化 JimV 请求已被接受',
  27. message='JimV 已被初始化。页面将在5秒钟后自动跳转到实例列表页面!')
  28. else:
  29. return render_template('login.html')