awacke1's picture
Update app.py
e2e8cd9
#Write a streamlit program in short number of lines that has four buttons on a sidebar also with a textbox labeled Github URL. Create python code that performs the four functions with github : Pull & Read, Append and Write, Create a file on github, Delete a file on github.
import streamlit as st
st.markdown("""
https://pypi.org/project/github3api/
github3api
https://pypi.org/project/github-archive/
# Install tool
pip3 install github-archive
# Install locally
make install
""")
def pull_files_from_github_url(url):
import os
#client = GitHubAPI()
#client.get('/rate_limit')['resources']['core']
# Using GitPython library
# from git import Repo
# Get the directory where the file will be downloaded
# dir_name = os.path.basename(url).split('.')[0]
# Clone the repo
#
dir_name = 'c:\\users\\awacke1\\'
Repo.clone_from(url, dir_name)
# Get the list of files
# repo = Repo(dir_name)
# return [item.a_path for item in repo.tree.traverse()]
url = st.sidebar.text_input("GitHub URL")
url = 'https://github.com/AaronCWacker/Yggdrasil'
st.sidebar.title('GitHub Functions')
if st.sidebar.button("Pull & Read"):
pull_files_from_github_url(url)
if st.sidebar.button("Append & Write"):
pull_files_from_github_url(url)
if st.sidebar.button("Create File"):
pull_files_from_github_url(url)
if st.sidebar.button("Delete File"):
pull_files_from_github_url(url)