GithubHelp home page GithubHelp logo

fast-api-blog's Introduction

Setup project on local

mkdir var

# NOTE: create virtual environemnt
python3.11 -m venv var/env

# NOTE: install requirements
pip install -r src/requirements.txt

Run the application

VSCode launch.json

Easier for the user would be to create .vscode/launch.json launch configuration files in the project's root directory which would take care to run the backend & worker w/ VSCode debugger.

Windows

  • User must replace <REDIS_CS> & <MONGODB_CS> values w/ real connection strings
  • For windows it is required for python RQ to use worker class worker.workers.BasicWindowsWorker, which is done using -w flag in the RQ worker command
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "FastAPI Server",
            "type": "python",
            "request": "launch",
            "module": "uvicorn",
            "cwd": "${workspaceFolder}/src",
            "args": [
                "main:app",
                "--reload"
            ],
            "env": {
                "MONGODB_CS": "<MONGODB_CS>",
                "REDIS_CS": "<REDIS_CS>"
            },
            "jinja": true,
            "justMyCode": true
        },
        {
            "name": "RQ Worker",
            "type": "python",
            "request": "launch",
            "module": "rq.cli",
            "cwd": "${workspaceFolder}/src",
            "args": [
                "worker",
                "-w",
                "worker.workers.BasicWindowsWorker",
                "--url",
                "<REDIS_CS>"
            ],
            "env": {
                "MONGODB_CS": "<MONGODB_CS>",
                "REDIS_CS": "<REDIS_CS>"
            },
            "jinja": true,
            "justMyCode": true
        }
    ]
}

Setup services

MongoDB

MongoDB Atlas

Easier for the user would be to setup the Atlas database & use it.

Docker

To run the database using docker use the command below or Docker Desktop (for windows)

# TODO: go to the project root & make sure you have directory named "var"

# NOTE: pull the image
docker pull mongo:latest

# NOTE: run the image
docker run -ti -p 27017:27017 -v ./var/mongodb:/data/db mongo:latest

# NOTE: MONGO_CS=mongodb://localhost:27017

Redis

Redis Cloud

Easier for the user would be to setup the Redis labs database & use it.

Docker

To trun the redis using docker use the command below or Docker Desktop (for windows)

# NOTE: pull the image
docker pull redis:alpine

# NOTE: run the image
docker run -ti redis:alpine

# NOTE: REDIS_CS=redis://localhost:6379

fast-api-blog's People

Contributors

m3ck0 avatar

Watchers

 avatar

Forkers

d4vm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.