Skip to content

Latest commit

 

History

History
 
 

README.md

SANIC SIMPLE API

What’s In This Document


  1. Quickstart
  2. Database testing
  3. Reference

🚀 Quickstart

Project provide two mode environments is development and production, the development environment used when development process and the production environment used to deployed in server You can run the project on your local environment with these steps:

  1. Setup python virtual environment and install libraries
  • To create virtual environment, run command:

    python3 -m venv venv

    Or you can use Add Interpreter in PyCharm

  • Activity virtual environment in ubuntu:

    source venv/bin/activate
  • Install libraries

    pip3 install -r requirements.txt
  1. Start Trava API in development mode
    To start API with development environment, simply you run

    make rundev

    If you want to run project with custom environment, you run following:

    make rundocker

    You want to run project directly without docker, run following:

    make run
  • to get more information, you can run:

    make help
  • After your app ran, you can follow here to test api


Database testing

  • How to execute database docker container

    docker exec -it dev_sanic_sql_container bash
  • Login default user with password is sanic

    mysql -u root -p
  • Switching to sanic_app database

    use sanic_app;
  • End then you can enter your query command in console line.


Pre commit

My project use pre-commit to check code before pushing to git. You can find all setup and command line in here. In this article, i simply introduce some useful command line

  • Install pre-commit to git hook
pre-commit install
  • Run pre-commit manually
pre-commit run --all-files
  • Learn command line rule
pre-commit --help

Reference