login.py 639 B

123456789101112131415161718192021222324252627
  1. """
  2. 登录接口
  3. """
  4. from flask import Blueprint
  5. from flask import request
  6. import api
  7. import instagram
  8. login_opt = Blueprint('login', __name__)
  9. @login_opt.route('/createPage', methods=["POST"])
  10. def create_page():
  11. """
  12. 登录接口
  13. """
  14. request_body = request.json
  15. account = request_body.get('account')
  16. if not api.contain_browser(account):
  17. browser = instagram.InstagramBrowser(account)
  18. browser.__init_browser__(playwright=None)
  19. browser.page.goto(instagram.IG_URL)
  20. browser.page.wait_for_timeout(60000)
  21. browser.close()
  22. api.add_account(account)
  23. return api.success()