1
0

6.flask_coroutine.py 992 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import subprocess
  2. import time
  3. from selenium.webdriver import Chrome
  4. import pywebio
  5. import template
  6. import util
  7. from pywebio.input import *
  8. from pywebio.platform.flask import start_server
  9. from pywebio.utils import to_coroutine
  10. async def target():
  11. template.basic_output()
  12. await template.coro_background_output()
  13. await to_coroutine(template.basic_input())
  14. await actions(buttons=['Continue'])
  15. await template.flask_coro_background_input()
  16. def test(server_proc: subprocess.Popen, browser: Chrome):
  17. template.test_output(browser, action_delay=1)
  18. time.sleep(1)
  19. template.test_input(browser, action_delay=1.5)
  20. time.sleep(1)
  21. template.save_output(browser, '6.flask_coroutine.html')
  22. def start_test_server():
  23. pywebio.enable_debug()
  24. start_server(target, port=8080, host='127.0.0.1', cdn=False)
  25. if __name__ == '__main__':
  26. util.run_test(start_test_server, test, address='http://localhost:8080?_pywebio_debug=1&_pywebio_http_pull_interval=400')