Spaces:
Running
Running
File size: 942 Bytes
c383152 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import watchfiles
import logging
import sys
# Configure logging to provide feedback on the watcher's status
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
if __name__ == '__main__':
"""
This script uses 'watchfiles' to monitor for file changes in the current
directory (and subdirectories) and automatically restarts the Gradio
application.
It's a convenient way to develop without manually stopping and restarting
the server after each code change.
To run:
python run_dev_server.py
"""
logging.info("Starting file watcher and development server for app.py...")
# run_process will watch for changes in the current path ('.')
# and restart the target command.
watchfiles.run_process(
'.', # Watch the current directory
target=f'{sys.executable} app.py --color', # Command to run
target_type='command'
)
|