- Inline completions for new routes
- Inline chat refinements
- Comment-driven code generation
- Next-edit suggestions for refactoring
Prerequisites
- Python ≥ 3.7
- Flask installed (
pip install flask) - GitHub Copilot extension enabled in your editor
- Basic knowledge of RESTful APIs
This demo uses an in-memory database (
items_db). For production workloads, integrate a persistent data store like PostgreSQL or MongoDB.1. Basic Flask App with In-Memory DB
Start with a simple Flask application. Create anapp.py file:
2. Deleting All Items
Type a new route decorator and function signature:3. Generating Random Items
Define a “create random items” endpoint:4. Inline Chat: Analyze Numbers
Start with:4.1 Enhanced Validation & Stats
Refine the route for stronger validation:5. Comment-Driven Suggestions
Write a descriptive comment, then let Copilot generate code:6. Next-Edit Suggestions for Refactoring
Enable Next-Edit Suggestions in Copilot settings to receive automated refactors. Example: renamingitems_db to items_db_new.
Before:
Enabling Next-Edit Suggestions
Open GitHub Copilot settings and search for next edit suggestions. Toggle it on under the Preview options: