A web application built for CSYE6225.
Please ensure the following is installed for the webapp to run locally.
- Python - 3.11+
- PostgreSQL
- pip
-
Access PostgreSQL: Use the psql command.
sudo -u <db_username> psql
Replace <db_username> with your PostgreSQL db_username or
postgresif you're using the default superuser. -
Create Database: (Optional) Once inside psql, create a new database
CREATE DATABASE csye6225_db; -
Create User and Assign Privileges: create a new user and assign it specific privileges on the database
CREATE USER <db_username> WITH PASSWORD 'db_password'; GRANT ALL PRIVILEGES ON DATABASE csye6225_db TO <username>;
git clone https://github.com/RAJ-SUDHARSHAN/webapp.git
cd webapp/python -m venv venv
source venv/bin/activate
pip install -r requirements.txtCreate .env file inside the webapp directory and set the variables
FLASK_APP=app
FLASK_DEBUG=True
DATABASE_URL=postgresql://<db_username>:<db_password>@localhost:5432/csye6225_db
CSV_PATH=./users.csv- Initialize migrations:
flask db init
- Create migration:
flask db migrate -m "Description of the changes" - Apply migrations:
flask db upgrade
To populate the values from the csv file, execute this command.
flask populate_dbflask run --port 5000Once the application is running, check if the database and application are properly connected by accessing the healthz endpoint. A 200 status code indicates that the connection is successful.
To test, execute the below command in the terminal.
curl -vvvv http://localhost:5000/healthz