GitXplorerGitXplorer
a

content-suggestion

public
1 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
e8f950e532fc7861b80df809ba567a5455dc89d5

update readme

aakmarzhan1 committed 3 years ago
Verified
57fee413ff341c6a265b267797dc4bee0af8a49b

Update README.md

aakmarzhan1 committed 3 years ago
Verified
ffc1a3687654af06d6d7c626cc784238efe45000

fix readme

aakmarzhan1 committed 3 years ago
Verified
940efe6af5d1b36a772599701edc38bc38a3e650

Update README.md

aakmarzhan1 committed 4 years ago
Verified
007a19ec5cc9a6d62c804bc904126d5a3011bddc

Update README.md

aakmarzhan1 committed 4 years ago
Verified
ee16e638b46092b543a136cc61791c7d82bbf002

Add files via upload

aakmarzhan1 committed 4 years ago

README

The README file for this repository.

Welcome to the Content Suggestion tool

Welcome to the Content Suggestion Team Project! This is a copy of the original repo (which is private and owned by Minerva University). The project was co-created with couple other students and is an Instagram suggestion tool that provides account analytics and recommendations for future content with an automated CI/CD pipeline (on the original repo through TravisCI and Github Actions). It uses Jinja2, Bootstrap and basic CSS/HTML for the front-end, while making use of Flask, SQLAlchemy, PostgreSQL, BeautifulSoup and instagram-scraper for the back-end. There are also multiple unit and integration tests spanning various features.

Below are some screenshots from the website:

image image image

You have two options to access this project: through Heroku and by manually downloading and running locally.

Heroku Deployment

The link to the Heroku website: https://content-suggestion.herokuapp.com/

The initial Figma prototype can be accessed here: https://www.figma.com/file/vrpi5Gtfw80gj8RYzmrxMT/CS162?node-id=8%3A162

Run Virtual Environment

Virtual environment is a key component in ensuring that the application is configured in the right environment. To run the project locally, make sure you follow the next steps:

Requirements
  • Python 3
  • Pip 3
$ brew install python3

Pip3 is installed with Python3

Installation

To install virtualenv via pip run:

$ pip3 install virtualenv
Usage

Creation of virtualenv:

$ virtualenv -p python3 venv

If the above code does not work, you could also do

$ python3 -m venv venv

To activate the virtualenv:

$ source venv/bin/activate

Or, if you are using Windows - reference source:

$ venv\Scripts\activate

To deactivate the virtualenv (after you finished working):

$ deactivate

Install dependencies in virtual environment:

$ pip3 install -r requirements.txt

Environment Variables

All environment variables are stored within the .env file and loaded with dotenv package.

Never commit your local settings to the Github repository!

Run Application

Start the server by running:

$ export FLASK_ENV=dev
$ export FLASK_APP=web
$ python3 -m flask run

If using Windows, use 'set' instead of 'export'

Unit Tests

To run the unit tests use the following commands:

$ python3 -m venv venv_unit
$ source venv_unit/bin/activate
$ pip install -r requirements-unit.txt
$ export FLASK_ENV=test
$ export DATABASE_URL='sqlite:///web.db'
$ export SECRET_KEY='testing_key'
$ pytest unit_test

Integration Tests

To run integration tests you need to start your containers and then run tests:

$ python3 -m venv venv_integration
$ source venv_integration/bin/activate
$ pip3 install -r requirements-integration.txt
$ export FLASK_ENV=test
$ export DATABASE_URL="mysql+pymysql://root:test_password@127.0.0.1:3306/main"
$ docker-compose build --no-cache
$ docker-compose up -d --force-recreate
$ pytest integration_test
$ docker-compose down

Flask-Migrate

Flask-Migrations is an extensions that manages DB migrations, common commands:

flask db migrate (create migration) flask db upgrade (implement migration in the DB)

Sending Emails Template

The app can send emails using the following template:

from .mail import mail

msg = Message(subject="email_subject", 
sender="no-reply@suggestme.com", 
recipients=[recipient_email@gmail.com])
msg.html = render_template("html_file_name_here.html")
mail.send(msg)

Form Templates

Standardized form template that can be used in any view:

First import render_field, it's a template that will render form fields and show their respective errors in case there is any.

{% from "_formhelpers.html" import render_field %}

Then you can create forms by calling render_field(form_data, placeholder="test"):

<form method=post>
    {{ form.hidden_tag() }}
    {{ render_field(form.data1, placeholder="Data 1") }}
    {{ render_field(form.data2, placeholder="Data 2") }}
    <p><input type=submit value="Submit">
</form>

There's also an optional extra line before submit, if you want to send 'flash' alerts to your form.

{% include "_messages.html" %}