6.flask_coroutine.py 987 B

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