Skip to content

Commit 951e257

Browse files
docs: add 'Course' section to navigation and expand course content with detailed day-by-day topics for enhanced learning experience
1 parent 7b1eb52 commit 951e257

File tree

19 files changed

+4051
-8064
lines changed

19 files changed

+4051
-8064
lines changed

docs/.vitepress/config.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default defineConfig({
3333
{ text: 'API Reference', link: '/api/application' },
3434
{ text: 'Examples', link: '/api-examples' },
3535
{ text: 'Team', link: 'team' },
36+
{ text: 'Course', link: '/course/index' },
3637
],
3738

3839
sidebar: {
@@ -142,6 +143,43 @@ export default defineConfig({
142143
]
143144
}
144145
],
146+
'/course/': [
147+
{
148+
text: 'Course',
149+
items: [
150+
{ text: 'Day 1 (Introduction to Nexios)', link: '/course/day01' },
151+
{ text: 'Day 2 (Routing in Nexios)', link: '/course/day02' },
152+
{ text: 'Day 3 (Async, Request, and Response)', link: '/course/day03' },
153+
{ text: 'Day 4 (Class-Based Views with APIHandler)', link: '/course/day04' },
154+
{ text: 'Day 5 (Middleware in Nexios)', link: '/course/day05' },
155+
{ text: 'Day 6 (Configuration in Nexios)', link: '/course/day06' },
156+
{ text: 'Day 7', link: '/course/day07' },
157+
{ text: 'Day 8', link: '/course/day08' },
158+
{ text: 'Day 9', link: '/course/day09' },
159+
{ text: 'Day 10', link: '/course/day10' },
160+
{ text: 'Day 11', link: '/course/day11' },
161+
{ text: 'Day 12', link: '/course/day12' },
162+
{ text: 'Day 13', link: '/course/day13' },
163+
{ text: 'Day 14', link: '/course/day14' },
164+
{ text: 'Day 15', link: '/course/day15' },
165+
{ text: 'Day 16', link: '/course/day16' },
166+
{ text: 'Day 17', link: '/course/day17' },
167+
{ text: 'Day 18', link: '/course/day18' },
168+
{ text: 'Day 19', link: '/course/day19' },
169+
{ text: 'Day 20', link: '/course/day20' },
170+
{ text: 'Day 21', link: '/course/day21' },
171+
{ text: 'Day 22', link: '/course/day22' },
172+
{ text: 'Day 23', link: '/course/day23' },
173+
{ text: 'Day 24', link: '/course/day24' },
174+
{ text: 'Day 25', link: '/course/day25' },
175+
{ text: 'Day 26', link: '/course/day26' },
176+
{ text: 'Day 27', link: '/course/day27' },
177+
{ text: 'Day 28', link: '/course/day28' },
178+
{ text: 'Day 29', link: '/course/day29' },
179+
{ text: 'Day 30', link: '/course/day30' },
180+
]
181+
}
182+
]
145183
}
146184
},
147185

docs/course/day01/index.md

Lines changed: 111 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,77 @@
11
# Day 1: Introduction to Nexios
22

3-
Welcome to your first day of learning Nexios! Today, we'll cover the fundamentals and create our first Nexios application.
3+
## What You'll Learn
4+
- What Nexios is and its core features
5+
- How to install Nexios and set up your environment
6+
- Creating your first Nexios application
7+
- Understanding the basic project structure
48

5-
## What is Nexios?
9+
## Core Concepts
610

7-
Nexios is a modern, fast, and flexible Python web framework designed for building APIs and web applications. It features:
8-
- Async-first architecture
9-
- Type hints support
10-
- Intuitive routing
11-
- Built-in middleware system
12-
- Extensive plugin ecosystem
11+
### What is Nexios?
1312

14-
## Installation and Setup
13+
Nexios is a modern, high-performance Python web framework designed for building async APIs and web applications. It combines the best of modern Python features with an intuitive API design.
1514

16-
1. Create a new project directory:
15+
#### Key Features
16+
- Async-first architecture for high performance
17+
- Type-safe development with full type hints
18+
- Intuitive and expressive routing
19+
- Flexible middleware system
20+
- Rich plugin ecosystem
21+
- Modern Python (3.9+) features
22+
23+
## Setting Up Your Environment
24+
25+
### Prerequisites
26+
Make sure you have:
27+
- Python 3.9 or higher
28+
- pip (Python package manager)
29+
- A code editor (VS Code recommended)
30+
31+
### Installation Steps
32+
33+
1. Create a project directory:
1734
```bash
1835
mkdir my-nexios-app
1936
cd my-nexios-app
2037
```
2138

22-
2. Create and activate a virtual environment:
23-
```bash
39+
2. Set up a virtual environment:
40+
::: code-group
41+
```bash [Linux/Mac]
2442
python -m venv venv
25-
source venv/bin/activate # Linux/Mac
26-
venv\Scripts\activate # Windows
43+
source venv/bin/activate
2744
```
2845

46+
```bash [Windows]
47+
python -m venv venv
48+
venv\Scripts\activate
49+
```
50+
:::
51+
2952
3. Install Nexios:
3053
```bash
3154
pip install nexios
3255
```
3356

34-
## Your First Nexios Application
57+
::: tip 💡 Best Practice
58+
Always use a virtual environment to keep your project dependencies isolated!
59+
:::
60+
61+
## Your First Nexios App
62+
63+
### Project Structure
64+
```
65+
my-nexios-app/
66+
├── venv/
67+
└── app.py
68+
```
69+
70+
### Basic Application
3571

36-
Let's create a simple "Hello, World!" application:
72+
Create `app.py`:
3773

3874
```python
39-
# app.py
4075
from nexios import NexiosApp
4176
from nexios.http import Request, Response
4277

@@ -45,7 +80,7 @@ app = NexiosApp()
4580

4681
# Define a route
4782
@app.get("/")
48-
async def index(request: Request, response: Response):
83+
async def hello(request: Request, response: Response):
4984
return response.json({
5085
"message": "Hello, World!",
5186
"framework": "Nexios"
@@ -57,132 +92,88 @@ if __name__ == "__main__":
5792
uvicorn.run(app, host="127.0.0.1", port=5000, reload=True)
5893
```
5994

60-
## Understanding the Code
61-
62-
Let's break down the key components:
63-
64-
1. **Imports**:
65-
- `NexiosApp`: The main application class
66-
- `Request`: Handles incoming HTTP requests
67-
- `Response`: Manages HTTP responses
95+
::: details 🔍 Code Breakdown
96+
1. **Imports**:
97+
- `NexiosApp`: The core application class
98+
- `Request`: Handles incoming request data
99+
- `Response`: Manages response formatting
68100

69-
2. **Application Instance**:
70-
```python
71-
app = NexiosApp()
72-
```
73-
Creates a new Nexios application instance.
101+
2. **App Creation**:
102+
- `app = NexiosApp()` initializes your application
74103

75-
3. **Route Decorator**:
76-
```python
77-
@app.get("/")
78-
```
79-
Defines a route handler for GET requests to the root path ("/").
104+
3. **Route Definition**:
105+
- `@app.get("/")` defines a GET route
106+
- The handler function is async for better performance
80107

81-
4. **Route Handler**:
82-
```python
83-
async def index(request: Request, response: Response):
84-
```
85-
- Async function that handles the request
86-
- Takes `request` and `response` parameters
87-
- Returns a JSON response
108+
4. **Running the App**:
109+
- Uses `uvicorn` as the ASGI server
110+
- Development mode with auto-reload enabled
111+
:::
88112

89-
5. **Running the App**:
90-
```python
91-
uvicorn.run(app, host="127.0.0.1", port=5000, reload=True)
92-
```
93-
Starts the development server with hot reload enabled.
113+
## Working with Responses
94114

95-
## Basic Response Types
115+
Nexios supports multiple response types:
96116

97-
Nexios supports various response types:
98-
99-
```python
100-
# JSON Response
101-
@app.get("/json")
117+
::: code-group
118+
```python [JSON Response]
119+
@app.get("/api/data")
102120
async def json_handler(request, response):
103-
return response.json({"message": "Hello, World!"})
121+
return response.json({
122+
"status": "success",
123+
"data": {"message": "Hello, World!"}
124+
})
125+
```
104126

105-
# Text Response
127+
```python [Text Response]
106128
@app.get("/text")
107129
async def text_handler(request, response):
108130
return response.text("Hello, World!")
131+
```
109132

110-
# HTML Response
133+
```python [HTML Response]
111134
@app.get("/html")
112135
async def html_handler(request, response):
113136
return response.html("<h1>Hello, World!</h1>")
114137
```
138+
:::
115139

116-
## Exercises
117-
118-
1. **Basic Route**:
119-
Create a route that returns your name and favorite programming language.
120-
121-
2. **Multiple Routes**:
122-
Add routes for `/about` and `/contact` that return different JSON responses.
123-
124-
3. **Custom Headers**:
125-
Modify the index route to include a custom header `X-Powered-By: Nexios`.
126-
127-
## Mini-Project: Simple API
140+
## Practice Exercise
128141

129-
Create a simple API with the following endpoints:
130-
1. GET `/api/items` - Returns a list of items
131-
2. GET `/api/items/{item_id}` - Returns a specific item
142+
Create a simple API with multiple endpoints:
132143

133144
```python
134-
from nexios import NexiosApp
135-
136-
app = NexiosApp()
145+
@app.get("/about")
146+
async def about(request, response):
147+
return response.json({
148+
"app_name": "My First Nexios App",
149+
"version": "1.0.0",
150+
"author": "Your Name"
151+
})
137152

138-
# Sample data
139-
items = [
140-
{"id": 1, "name": "Item 1"},
141-
{"id": 2, "name": "Item 2"},
142-
{"id": 3, "name": "Item 3"}
143-
]
144-
145-
@app.get("/api/items")
146-
async def get_items(request, response):
147-
return response.json(items)
148-
149-
@app.get("/api/items/{item_id:int}")
150-
async def get_item(request, response):
151-
item_id = request.path_params.item_id
152-
item = next((item for item in items if item["id"] == item_id), None)
153-
if item:
154-
return response.json(item)
155-
return response.json({"error": "Item not found"}, status_code=404)
153+
@app.get("/status")
154+
async def status(request, response):
155+
return response.json({
156+
"status": "healthy",
157+
"timestamp": datetime.now().isoformat()
158+
})
156159
```
157160

158-
## Key Concepts Learned
159-
160-
- Setting up a Nexios application
161-
- Creating basic routes
162-
- Handling requests and responses
163-
- Working with JSON data
164-
- Basic path parameters
165-
- HTTP status codes
161+
## Homework
162+
1. Create a new Nexios application
163+
2. Add at least 3 different endpoints
164+
3. Use different response types (JSON, text, HTML)
165+
4. Add basic error handling
166+
5. Test your endpoints using a tool like curl or Postman
166167

167168
## Additional Resources
168-
169-
- [Nexios Documentation](https://nexios.dev)
170-
- [API Examples](https://nexios.dev/examples)
171-
- [GitHub Repository](https://github.com/yourusername/nexios)
172-
173-
## Homework
174-
175-
1. Add more routes to the mini-project:
176-
- GET `/api/items/search?name=query` - Search items by name
177-
- GET `/api/status` - Return API status and version
178-
179-
2. Experiment with different response types:
180-
- Try returning HTML
181-
- Add custom headers
182-
- Use different status codes
183-
184-
3. Read the documentation on routing and responses
169+
- [Official Nexios Documentation](https://nexios.dev)
170+
- [Python Async/Await Guide](https://docs.python.org/3/library/asyncio.html)
171+
- [Modern Python Features](https://docs.python.org/3/whatsnew/3.7.html)
185172

186173
## Next Steps
187-
188-
Tomorrow, we'll dive deeper into routing patterns and request handling in [Day 2: First Application & Routing](../day02/index.md).
174+
Tomorrow in [Day 2: Routing in Nexios](../day02/index.md), we'll explore:
175+
- Route parameters and patterns
176+
- HTTP methods
177+
- Query parameters
178+
- Path parameters
179+
- Request body handling

0 commit comments

Comments
 (0)