Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,26 @@ import requests
|
|
| 4 |
|
| 5 |
app = Flask(__name__)
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
@app.route("/drive.com/files")
|
| 8 |
def index():
|
| 9 |
ip = request.remote_addr
|
|
|
|
| 4 |
|
| 5 |
app = Flask(__name__)
|
| 6 |
|
| 7 |
+
watcher_process = None
|
| 8 |
+
|
| 9 |
+
def start_watcher():
|
| 10 |
+
global watcher_process
|
| 11 |
+
|
| 12 |
+
if watcher_process is None or watcher_process.poll() is not None:
|
| 13 |
+
watcher_process = subprocess.Popen(
|
| 14 |
+
[sys.executable, "watcher.py"],
|
| 15 |
+
stdout=sys.stdout,
|
| 16 |
+
stderr=sys.stderr,
|
| 17 |
+
env=os.environ, # ← 環境変数を引き継ぐ
|
| 18 |
+
)
|
| 19 |
+
print("watcher.py を起動しました")
|
| 20 |
+
|
| 21 |
+
@app.before_first_request
|
| 22 |
+
def startup():
|
| 23 |
+
start_watcher()
|
| 24 |
+
|
| 25 |
+
#----------
|
| 26 |
+
|
| 27 |
@app.route("/drive.com/files")
|
| 28 |
def index():
|
| 29 |
ip = request.remote_addr
|