Skip to content

canarymail/canary-backend-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Sanic Backend Boilerplate

A lightweight, high-performance API boilerplate built with the Sanic framework.

📖 About

This boilerplate provides a minimal setup for creating a REST API using the Sanic framework. Sanic is an async Python web server that's built to be fast, simple, and easy to use.

Sanic allows for asynchronous request handling, making it ideal for I/O-bound applications that require high throughput.

Documentation: https://sanic.dev/en/#production-ready

✨ Features

  • Asynchronous request handling
  • Simple CRUD API structure
  • CORS middleware configuration
  • Easy to extend and customize
  • Minimal dependencies
  • Type hints and modern Python practices

🛠️ Tech Stack

Prerequisites

  • Python 3.7+
  • pip (Python package manager)

🚦 Getting Started

Environment Setup

You can use any of the following methods to set up your environment:

Using venv (Python's built-in virtual environment)

# Create a virtual environment
python -m venv venv

# Activate the virtual environment
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate

Using conda

# Create a conda environment
conda create -n sanic-boilerplate python=3.9

# Activate the environment
conda activate sanic-boilerplate

Installing Requirements

Install the dependencies using pip:

pip install -r requirements.txt

Managing Requirements

  1. To add new requirements:

    • Add the package name to requirements.txt
    • Run pip install -r requirements.txt
  2. Alternatively, install directly and update requirements:

    pip install package-name
    pip freeze > requirements.txt

Running the Server

python main.py

The server will start on http://localhost:8000.

📁 Project Structure

sanic-boilerplate/
├── main.py          # Main application file with route definitions
├── requirements.txt # Project dependencies
└── README.md        # Project documentation

Endpoints

  • GET /ping - Health check endpoint
  • GET /api/items - Get all items
  • POST /api/items - Create a new item
  • PUT /api/items/:id - Update an item
  • DELETE /api/items/:id - Delete an item

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

🆘 Support

If you have any questions or run into issues, please:

  1. Check the Sanic documentation
  2. Open an issue in this repository

Happy coding! 🎉

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages