routes.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. from flask import render_template, Blueprint, request, redirect, url_for
  2. import requests
  3. from backstage.utils.routes import update_manage_table
  4. from backstage.config import PORTAL_SERVER, BHOUSE_SERVER
  5. home_app = Blueprint('home', __name__)
  6. @home_app.route('/backstage/home')
  7. def home():
  8. response = requests.get('{}manages/data?page=home'.format(PORTAL_SERVER))
  9. if response.status_code == 200:
  10. return render_template('home.html',
  11. title='首頁',
  12. form_url='home.update',
  13. page='home',
  14. contents=response.json(),
  15. bhouse_server=BHOUSE_SERVER)
  16. @home_app.route('/backstage/home/update', methods=['POST'])
  17. def update():
  18. update_manage_table(request.form.getlist('data'),
  19. request.form.getlist('element'),
  20. request.args,
  21. request.files.getlist('image'),
  22. 'home3')
  23. return redirect(url_for('home.home'))