Git Product home page Git Product logo

trading-system-1's Introduction

Config

  • APPLICATION_CONFIG is strictly related to my project and is used only to load a JSON configuration file with the name specified in the variable itself.

  • FLASK_CONFIG is used to select the Python object that contains the configuration for the Flask application (see application/app.py and application/config.py). The value of the variable is converted into the name of a class.

  • FLASK_ENV is a variable used by Flask itself, and its values are dictated by it. See the configuration documentation mentioned in the resources of the previous section.

  • Config database: SQLALCHEMY_DATABASE_URI = ( f"postgresql+psycopg2://ogwsmojrynkhmc:5e3f5b888472b53141e050ea3e366765203feab53b43a13248b65f718e477e63@ec2-52-86-2-228.compute-1.amazonaws.com:5432/dg0q8kfl0thi4" )

  • pg_dump -U admin -h localhost -p 5432 --clean -F p trading_system > trading_system1.sql // The default output format of pg_dump is actually plaintext sql script

  • psql -U ogwsmojrynkhmc -h ec2-52-86-2-228.compute-1.amazonaws.com -p 5432 -d dg0q8kfl0thi4 < trading_system1.sql

ogwsmojrynkhmc:5e3f5b888472b53141e050ea3e366765203feab53b43a13248b65f718e477e63@ec2-52-86-2-228.compute-1.amazonaws.com:5432/dg0q8kfl0thi4"

Run the app

  1. Give permission to manage.py
  • chmod 775 manage.py
  1. Create venv
  • sudo apt-get install python3-venv
  • sudo apt-get install python3-tk
  • python3 -m venv .venv
  • source .venv/bin/activate
  • pip3 install -r requirements/development.txt
  • python3 -m pip install
  • pip3 freeze > requirements.txt
  1. Init database
  • ./manage.py flask db init
  • ./manage.py flask db stamp head
  • ./manage.py flask db migrate
  • ./manage.py flask db upgrade
  1. Update database
  • ./manage.py flask db stamp head
  • ./manage.py flask db migrate
  • ./manage.py flask db upgrade
  1. Run flask with config
  • Run by flask command line: FLASK_CONFIG="development" flask run
  • Run with manage.py: ./manage.py flask run
  1. Build the image
  • FLASK_ENV="development" FLASK_CONFIG="development" docker-compose -f docker/development.yml build web
  • If you need to explore the container you can login directly with

docker exec -it docker_web_1 bash

or with

FLASK_ENV="development" FLASK_CONFIG="development" docker-compose -f docker/development.yml exec web bash

  • To tear down the containers, when running as daemon, you can run

FLASK_ENV="development" FLASK_CONFIG="development" docker-compose -f docker/development.yml down

  • If you need to explore the container you can login directly with

$ docker exec -it docker_web_1 bash

or with

$ FLASK_ENV="development" FLASK_CONFIG="development" docker-compose -f docker/development.yml exec web bash

  • Run ./manage.py compose up -d and ./manage.py compose down and have the environment variables automatically passed to the system

Install package

  • python3 -m pip install flask_jwt_extended
  • python3 -m pip install flask_mail
  • python3 -m pip install marshmallow
  • python3 -m pip install webargs

Unit test

  • Run pytest

Notes

  • Need to install: sudo apt-get install libpq-dev before installing the 'psycopg2' library
  • Permission Denied for docker-compose: try with sudo
  • Redundant dependencies: distro-info===0.23ubuntu1 duplicity==0.8.12.0 language-selector==0.1 louis==3.12.0 python-apt==2.0.0+ubuntu0.20.4.1 python-debian===0.1.36ubuntu1 systemd-python==234 typed-ast==1.4.1 ubuntu-advantage-tools==20.3 toml==0.10.1 ubuntu-drivers-common==0.0.0 SQLAlchemy==1.3.19

To learn

@wraps(func) def wrapper(*args, **kwargs): make_response decorators @staticmethod @property updated_at = db.Column(db.DateTime(), nullable=False, default=lambda: datetime.utcnow()) created_at = db.Column(db.DateTime(), nullable=False, default=lambda: datetime.utcnow()) def init(self,*args,**kwargs): from flask_login import login_required, login_user, logout_user from werkzeug.security import check_password_hash @functools.wraps(func) def wrapper(*args, **kwargs): @post_load from opbeat.contrib.flask import Opbeat opbeat = Opbeat()

Done

Problems

  • The following paths are ignored by one of your .gitignore files: dbconfig Use -f if you really want to add them. git check-ignore -v -f dbconfig

trading-system-1's People

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.