Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

utmgdsc/back-end-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend Workshop

In this workshop we go over AWS, Flask, and Back-end development as whole! The slides can be found here

Installation

First clone the repository and open it in the terminal.

Assuming you already have Python 3 installed. The first thing you need to do is download Flask, Flask SQLAlchemy, dotenv and psycopg2-binary for making this application run as follows:

pip3 install Flask Flask-SQLAlchemy psycopg2-binary python-dotenv 

You will have to set up a PostgreSQL database by yourself (you can set it up on AWS like we did in the workshop or run it locally using a tool like this . Once that is done follow the next steps.

We need to set up the .env file which will be used to connect the database to flask.

  1. Create a .env file in the main directory
touch .env
  1. Edit .env file and put in the variable you need to setup the database such as username, password, etc.

For example:

HOST=124.256.289.10
USERNAME=google
PASSWORD=alexa

Why we use .env?

Since we do not want to put our credentials online for anyone to see. We create a .env file which containes these information for us. This .env file is added to .gitignore file so that any changes to this file is not registered by git.

Running the application

To run the API we need to run the API file with python3 as shown:

python3 ./src/api.py

Example usage (We recommend using a tool like Postman to send these requests)

GET /api/article
GET /api/article/:id
POST /api/article

Expected Type: raw JSON

Expected Data: {
    'title': 'Welcome to GDSC',
    'author': 'gdscutm',
    'body': 'Lists of workshop'
}
PUT /api/article/:id

Expected Type: raw JSON

Expected Data: {
    'title': 'Welcome to UTMGDSC'
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages