Quick Start Guide
This section provides an overview of Quick Start Guide.
Quick Start Guide
This guide will help you quickly get started with Chalpak, set up a simple application, and understand the basic file structure.
Prerequisites
Before you begin, make sure you have the following installed:
- Python 3.7 or higher
- pip (Python package installer)
Creating Your First Chalpak Application
Let's create a simple Chalpak application with two routes: one that returns JSON data and another that renders an HTML template.
Step 1: Create Project Directory
First, create a new directory for your project:
mkdir my_chalpak_app
cd my_chalpak_app
Step 2: Create main.py
Create a file named main.py in your project directory and add the following code:
from chalpak.app import Chalpak
app = Chalpak(templates="templates")
@app.get("/salom/{name}")
async def salom(request, name):
return {"message": f"Salom, {name}!"}
@app.get("/html/{name}")
async def html_page(request, name):
return app.render("index.html", {"request": request, "name": name})
app.run()