This repository contains code for a simple web application that allows users to search for code snippets on GitHub using the GitHub API.
- Clone or download the repository.
- Set up a virtual environment (optional but recommended).
- Install dependencies using
pip install -r requirements.txt
. - Obtain a GitHub personal access token with the
repo
scope. - Set the GitHub token as an environment variable named
GITHUB_TOKEN
. - Run the Flask app using
python main.py
. - Open the web browser and navigate to
http://localhost:8080
. - Enter your search query in the provided input field and submit the form.
This file contains the main application logic implemented using Flask. It includes routes for rendering the search page (/
) and handling search queries (/search
). It also provides an endpoint to fetch the GitHub token for client-side authorization (/get-github-token
).
This JavaScript file handles the client-side functionality of the application. It makes use of the GitHub token obtained from the server to authenticate requests to the GitHub API. The script fetches search results asynchronously and displays them in a table format on the web page.
You can customize the application by:
- Modifying the HTML and CSS templates in the
templates
directory to change the appearance of the search page. - Adding additional functionality such as pagination or filtering options to enhance the user experience.
- Implementing error handling and refining the UI to provide better feedback to users.
To obtain a GitHub personal access token:
- Go to your GitHub account settings.
- Navigate to the "Developer settings" section.
- Click on "Personal access tokens" and generate a new token with the
repo
scope. - Copy the generated token and set it as the value of the
GITHUB_TOKEN
environment variable.