test.py 622 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env python3
  2. import justpy as jp
  3. import inspect
  4. import uvicorn
  5. import asyncio
  6. wp = jp.WebPage(delete_flag=False, head_html='<script>confirm = () => true;</script>')
  7. main = jp.Div(a=wp, text='This minimal test is working nicely. "LOOP" is printed every second.')
  8. main.add_page(wp)
  9. jp.justpy(lambda: wp, start_server=False)
  10. app = jp.app
  11. async def loop():
  12. while True:
  13. print('LOOP')
  14. await asyncio.sleep(1.0)
  15. jp.run_task(loop())
  16. def run():
  17. if not inspect.stack()[-2].filename.endswith('spawn.py'):
  18. uvicorn.run('test:app', host='0.0.0.0', port=80, lifespan='on', reload=True)
  19. run()