HTMLify
xxs23lrk1o.py
Views: 125 | Author: guest
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 30 31 32 33 34 35 36 37 38 39 40 41 42 | """ URL Shortner 26/06/2024 MIT Licence Author: Aman Babu Hemant """ try: import textual import requests except ImportError: import os os.system("pip install textual") os.system("pip install requests") from textual.app import App from textual.widgets import Input, Button, Static from requests import get class URLShortner(App): def compose(self): yield Input(id="long", placeholder="Long URL") yield Button("Shorten") yield Input(id="short", disabled=True) def on_button_pressed(self, e): long_url = app.query_one("#long").value if not (long_url.startswith("http://") or long_url.startswith("https://") ): return app.notify("URL must starts with https:// or https://") try: r = get("https://htmlify.artizote.com/api/shortlink?url="+long_url).json() s = app.query_one("#short") s.value = r["url"] except Exception as e: app.notify("Check your internet connection") app.notify(str(e)) app = URLShortner() app.run() |