config.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from flask import Blueprint, request, abort, url_for
  5. import requests
  6. from . import render
  7. __author__ = 'James Iter'
  8. __date__ = '2017/8/29'
  9. __contact__ = 'james.iter.cn@gmail.com'
  10. __copyright__ = '(c) 2017 by James Iter.'
  11. blueprint = Blueprint(
  12. 'v_config',
  13. __name__,
  14. url_prefix='/config'
  15. )
  16. def show():
  17. config_url = url_for('api_config.r_get', _external=True)
  18. config_ret = requests.get(url=config_url, cookies=request.cookies)
  19. config_ret = json.loads(config_ret.content)
  20. # 检测 JimV 的配置是否已被初始化,只有未被初始化时,才展现初始化配置页面
  21. if config_ret['state']['code'] == '404':
  22. abort(404)
  23. return render('config_show.html', config=config_ret['data'])
  24. def create():
  25. config_url = url_for('api_config.r_get', _external=True)
  26. config_ret = requests.get(url=config_url, cookies=request.cookies)
  27. config_ret = json.loads(config_ret.content)
  28. # 检测 JimV 的配置是否已被初始化,只有未被初始化时,才展现初始化配置页面
  29. if config_ret['state']['code'] == '404':
  30. return render('config_init.html')
  31. else:
  32. abort(404)