File size: 1,999 Bytes
1040085
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from repos import get_repo_info
from scrape import fetch_contribution_details, parse_contribution_details

def reply(username: str, token: str):
    base_str = f"<h2 align='center'>What a git-year, {username}!πŸ₯‚πŸŽ‰</h2>\n\n<br>\n\n<div align='center'><img src='https://logos-world.net/wp-content/uploads/2020/11/GitHub-Logo.png' alt='GitHub Logo' width=150></div>\n\n\n"
    contributions = fetch_contribution_details(username, token)
    contrib_str = parse_contribution_details(contributions)
    repocount, gained_stars, gained_forks, top_10_topics, top_10_languages = get_repo_info(username, token)
    gainings_string = f"### βœ… This year's achievements\n\n- πŸ“ You created **{repocount} repositories**\n- ⭐ You gained **{gained_stars} new stars**\n- 🍴 You gained **{gained_forks} new forks**\n\n### πŸͺ› This year's contributions\n\n"
    base_str+=gainings_string
    base_str+=contrib_str
    top_10_tops = [f"- `{el[0]}` was used in {el[1]} of your repositories" for el in top_10_topics]
    top_10_langs = [f"- **{k}** accounted for **{top_10_languages[k]}** of your code this year" for k in top_10_languages]
    tops_and_langs = "### πŸ““ Top 10 topics\n\n" + "\n".join(top_10_tops) + "\n\n" + "### πŸ’» Top 5 languages\n\n" + "\n".join(top_10_langs) + "\n\n"
    base_str+=tops_and_langs
    return base_str

mytheme = gr.themes.Monochrome(font=gr.themes.Font("sans-serif"))

iface = gr.Interface(fn=reply, inputs=[gr.Textbox(label="GitHub Username", info="Insert your username here"), gr.Textbox(type="password", label="GitHub Token", info="Insert a GitHub token with repository-level access (<a href='https://github.com/settings/tokens'>find/create yours here</a>)")], outputs=gr.Markdown(label="Your output will be displayed here"), title="<h1 align='center'>What A Git-Year!πŸ₯³</h1>\n<h2 align='center'>Find out about your contributions on GitHub in the last yearπŸ“†</h2>\n<br>", theme=mytheme)

iface.launch(server_name="0.0.0.0", server_port=7860)