import pyshorteners

def shorten_url(url):
    shortener = pyshorteners.Shortener()
    short_url = shortener.tinyurl.short(url)
    return short_url

# URL 단축 예제
long_url = "<https://infosecwriteups.com/demystifying-pyinstaller-a-journey-into-decompiling-python-executables-abb84ef5a7bb>"
short_url = shorten_url(long_url)
print("Short URL:", short_url)
import pyshorteners
import streamlit as st

def shorten_url(url):
    shortener = pyshorteners.Shortener()
    short_url = shortener.tinyurl.short(url)
    return short_url

def main():
    st.title("URL Shortener")
    st.write("URL 주소를 입력하시면, Short URL이 생성됩니다.")

    url = st.text_input("URL 입력")

    if st.button("Shorten"):
        if url:
            short_url = shorten_url(url)
            st.success("Shortened URL:")
            st.write(short_url)

        else:
            st.warning("URL을 입력하세요.")

if __name__ == "__main__":
    main()
import pandas as pd
import pyshorteners
import streamlit as st
from io import BytesIO

def shorten_url(url):
    shortener = pyshorteners.Shortener()
    short_url = shortener.tinyurl.short(url)
    return short_url

def process_excel(file):
    df = pd.read_excel(file)
    df["Short URL"] = df["Long URL"].apply(shorten_url)
    return df

def main():
    st.title("Excel URL Shortener")

    # 엑셀 파일 업로드
    file = st.file_uploader("Upload Excel File", type=["xlsx"])

    if file is not None:
        # 엑셀 파일 처리
        df = process_excel(file)

        # 업데이트된 엑셀 파일 다운로드 링크 생성
        output_file = BytesIO()
        df.to_excel(output_file, index=False, engine='openpyxl')
        output_file.seek(0)
        st.download_button("Download Shortened URLs", data=output_file, file_name="shortened_urls.xlsx")

if __name__ == "__main__":
    main()

QRCode까지 생성

import pyshorteners
import streamlit as st
import qrcode
from PIL import Image
import io

def shorten_url(url):
    shortener = pyshorteners.Shortener()
    short_url = shortener.tinyurl.short(url)
    return short_url

def generate_qrcode(url):
    qr = qrcode.QRCode()
    qr.add_data(url)
    qr.make()
    qr_img = qr.make_image()

    # Convert PIL Image to bytes
    img_byte_array = io.BytesIO()
    qr_img.save(img_byte_array, format="PNG")
    img_bytes = img_byte_array.getvalue()

    return img_bytes

def main():
    st.title("URL Shortener and QR Code Generator")
    st.write("URL 주소를 입력하시면, Short URL과 해당 URL의 QR 코드가 생성됩니다.")

    url = st.text_input("URL 입력")

    if st.button("생성"):
        if url:
            short_url = shorten_url(url)
            qr_img_bytes = generate_qrcode(short_url)

            st.success("Shortened URL:")
            st.write(short_url)

            st.image(qr_img_bytes, caption=f"{short_url}'s QRcode", use_column_width=True)
        else:
            st.warning("URL을 입력하세요.")

if __name__ == "__main__":
    main()