LZT.BET Logo

Python Разработчик &
Мастер Веб-верстки

Информация

Что я могу?

Python - Telegram Bot

bot.py
Run bot.py

from telegram import Update
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext

def start(update: Update, context: CallbackContext) -> None:
    user = update.effective_user
    update.message.reply_html(
        f"Привет {user.mention_html()}! Отправь мне сообщение, и я его повторю.",
    )

def echo(update: Update, context: CallbackContext) -> None:
    update.message.reply_text(update.message.text)

def main() -> None:
    updater = Updater("YOUR_TOKEN")
    dispatcher = updater.dispatcher
    dispatcher.add_handler(CommandHandler("start", start))
    dispatcher.add_handler(MessageHandler(Filters.text & ~Filters.command, echo))
    updater.start_polling()
    updater.idle()

if __name__ == '__main__':
    main()
                    

Python - Requests

api_request.py
Run api_request.py

import requests
import json

def get_public_ip() -> str | None:
    try:
        response = requests.get('https://api.ipify.org?format=json', timeout=5)
        response.raise_for_status()
        
        data = response.json()
        ip_address = data.get('ip')
        return ip_address
        
    except requests.exceptions.RequestException as e:
        print(f"Ошибка при запросе: {e}")
        return None
    except json.JSONDecodeError:
        print("Ошибка декодирования JSON ответа.")
        return None

if __name__ == '__main__':
    my_ip = get_public_ip()
    if my_ip:
        print(f"Ваш публичный IP: {my_ip}")
    else:
        print("Не удалось получить IP.")
                    

HTML

index.html
View index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sample Page</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

    <header>
        <h1>Welcome!</h1>
    </header>

    <main>
        <p>This is a paragraph.</p>
    </main>

</body>
</html>