Daily Papers HN is a Python-based web application that displays academic papers in a Hacker News-like interface. It utilizes the Hugging Face Daily Papers API to fetch and present papers in a sortable, paginated list.
You can try out the Daily Papers HN application online without any local setup:
This demo is hosted on Hugging Face Spaces and provides the full functionality of the application.
- Backend: Python 3.7
- Web Framework: Gradio
- API Interaction: Requests library
- Data Processing: Custom
PaperManager
class - Hosting: Hugging Face Spaces
- Development Environment: Cursor with Claude 3.5-sonnet AI assistance
-
PaperManager Class: Handles paper fetching, sorting, and rendering
- Implements custom sorting algorithms: Hot, New, and Rising
- Manages pagination and paper formatting
-
API Integration:
- Endpoint:
https://huggingface.co/api/daily_papers
- Fetches up to 100 papers per request
- Endpoint:
-
Sorting Algorithms:
- Hot:
score = upvotes / ((time_diff_hours 2) ** 1.5)
- Rising:
score = upvotes / (time_diff_hours 1)
- New: Based on
publishedAt
timestamp
- Hot:
-
Gradio Interface:
- Utilizes
gr.Blocks
for layout - Implements custom CSS for Hacker News-like styling
- Responsive design with dark mode support
- Utilizes
-
Paper Fetching:
def fetch_papers(self): response = requests.get(f"{API_URL}?limit=100") self.raw_papers = response.json() self.sort_papers()
-
Sorting:
def sort_papers(self): if self.sort_method == "hot": self.papers = sorted(self.raw_papers, key=self.calculate_score, reverse=True) # Similar for "new" and "rising"
-
Rendering:
def render_papers(self): current_papers = self.papers[start:end] papers_html = "".join([self.format_paper(paper, idx) for idx, paper in enumerate(current_papers)]) return f"<table class='itemlist'>{papers_html}</table>"
-
Pagination:
def next_page(self): if self.current_page < self.total_pages: self.current_page = 1 return self.render_papers()
-
Clone the repository:
git clone https://github.com/your-username/dailypapersHN.git cd dailypapersHN
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
python app.py
-
Access the web interface at
http://127.0.0.1:7860
- The application uses Gradio's
gr.Blocks
for a flexible layout. - Custom CSS is implemented for styling, including dark mode support.
- Error handling is in place for API requests and data processing.
- The
PaperManager
class is designed for easy extension and modification of sorting algorithms.
- Implement caching to reduce API calls
- Add unit tests for sorting algorithms and rendering functions
- Explore asynchronous paper fetching for improved performance
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
The application is deployed on Hugging Face Spaces, which provides a serverless environment for hosting Gradio apps. To deploy your own version:
- Fork this repository to your GitHub account.
- Create a new Space on Hugging Face, linking it to your forked repository.
- Configure the Space to use the
app.py
file as the entry point. - Hugging Face Spaces will automatically deploy and update the app based on your repository changes.
Note: This application was developed using Cursor with Claude 3.5-sonnet AI assistance. This README was also generated with the assistance of Claude 3.5-sonnet in Cursor AI.