← Назад към блога
How to make Vrlin APP
**Python (`app.py`):** ```python from flask import Flask, request from flask_cors import CORS from tkinter import Tk, messagebox import threading app = Flask(__name__) CORS(app, origins="*") def show_popup(text): root = Tk() root.withdraw() # Make the dialog appear on top root.attributes("-topmost", True) root.lift() root.focus_force() messagebox.showinfo("Message", text, parent=root) root.destroy() @app.post("/run") def run(): data = request.get_json(silent=True) or {} text = str(data.get("text", "No message")) threading.Thread(target=show_popup, args=(text,), daemon=True).start() return {"status": "ok"} app.run("127.0.0.1", 5555) ``` Install Flask: ```bash pip install flask pip install flask-cors ``` Start the app: ```bash python app.py ``` **JavaScript:** ```javascript await fetch("http://127.0.0.1:5555/run", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: "Hello from JavaScript!" }) }); ``` Or: ```javascript body: JSON.stringify({ text: "Your download has finished." }) ``` Or: ```javascript body: JSON.stringify({ command: "ping google.com" }); ``` This way, the Python application runs continuously in the background, and your JavaScript code can send commands to it at any time via `localhost`. It's a lightweight solution that requires very little code.