Git Product home page Git Product logo

eeet2582-backend's Introduction

Setup Instructions

Prerequisites

  • Python 3.6 or higher

Environment variables setup

  1. Copy .env.example to .env
cd eeet2582_backend && cp .env.example .env

Database setup (Mac)

  1. Install openssl
brew install openssl
  1. Add path to openssl to bash profile
  1. Install required packages
pip3 install virtualenv
pip3 install psycopg
  1. Create new database (required that postgres is installed)
  • Open psql shell
psql
  • Create new database
CREATE DATABASE eeet2582_backend;
  1. Go back to project directory and run migrations
poetry install && poetry run manage.py migrate
  1. Finally, run the server
poetry run manage.py runserver

Superuser setup

  1. Create superuser (I'm using admin as username and password)
poetry run manage.py createsuperuser
  1. Go to http://localhost:8000/admin/ and login with the superuser credentials

Run server in virtual environment using poetry

poetry run manage.py runserver

Database setup (Win 11 & 10)

  1. Download & install choco package manager by following instruction from this link.
  2. Use choco to install OpenSSL. Please open the powershell in administration mode
choco install openssl
  1. Add path to openssl to win environment path (if the path is not added automaticly)
  • create new variable named as "OPENSSL_CONF" and add this path C:\Program Files\OpenSSL-Win64\bin\openssl.cfg as the its value.
  1. Install required packages
pip3 install virtualenv
pip3 install psycopg
  1. Create new database (required that postgres is installed)
  • Open psql shell
psql -U postgres
  • if the command isn't recognized, please add C:\Program Files\PostgreSQL\16\bin to the systen environemnt path

  • Create new database

CREATE DATABASE eeet2582_backend;
  • check if the database is created successfully
\l
  1. Go back to project directory and run migrations
  • install poetry dependecy management (if not)
pip3 install poetry
  • install the project && migrating the database
poetry install && poetry run python manage.py migrate
  1. Finally, run the server
poetry run python manage.py runserver

Superuser setup

  1. Create superuser (I'm using admin as username and password)
poetry run python manage.py createsuperuser
  1. Go to http://localhost:8000/admin/ and login with the superuser credentials

Run server in virtual environment using poetry

poetry run python manage.py runserver

Set up Celery for background tasks

  1. Install Redis
brew install redis
  1. Start Redis
brew services start redis
  1. Run Celery (in a new terminal)
celery -A eeet2582_backend worker --loglevel=info
  1. Flush Redis(only do to reset redis)
redis-cli flushall

run ngrok for Stripe webhook call

  1. After runing the server locally on port 8000
  2. download the ngrok.exe
  3. add authenticated token
ngrok config add-authtoken 2a1bssHACk98o1MV40hwaWna3TS_NpUqCqMpqfookK7DJaxb
  1. run ngrok at reserved domain
 ngrok http --domain smiling-narwhal-remotely.ngrok-free.app 8000

sudo apt install python3.12-dev sudo apt-get install libpq-dev

eeet2582-backend's People

Contributors

trinhduc9 avatar quynhethereal avatar dealoux avatar minhphan123 avatar cuongnguyen-rmit avatar

Watchers

 avatar

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.