Reformatting
This commit is contained in:
@@ -3,24 +3,26 @@
|
||||
Aktienbot API
|
||||
|
||||
## Development
|
||||
|
||||
1. Create virtual environment `python -m venv venv env/Scripts/activate`
|
||||
2. Install requirements `pip install -r api/requirements.txt`
|
||||
3. Set environment variables (see list below)
|
||||
1. Use `.env`-file in `api` directory like `.env.example`
|
||||
2. Or set variables using `export` or `set` commands. (Windows `set`, Linux `export`)
|
||||
4. Run api `python api/app.py`
|
||||
|
||||
1. Use `.env`-file in `api` directory like `.env.example`
|
||||
2. Or set variables using `export` or `set` commands. (Windows `set`, Linux `export`)
|
||||
4. Run api `python api/app.py`
|
||||
|
||||
## Testing
|
||||
|
||||
1. Create virtual environment `python -m venv venv env/Scripts/activate`
|
||||
2. Install requirements `pip install -r api/requirements.txt`
|
||||
3. Set environment variables (see list below)
|
||||
1. Use `.env`-file in `api` directory like `.env.example`
|
||||
2. Or set variables using `export` or `set` commands. (Windows `set`, Linux `export`)
|
||||
1. Use `.env`-file in `api` directory like `.env.example`
|
||||
2. Or set variables using `export` or `set` commands. (Windows `set`, Linux `export`)
|
||||
4. Change directory: `cd api/`
|
||||
5. Run tests: `python -m pytest -v --cov-report term-missing --cov=app`
|
||||
|
||||
## Environment variables
|
||||
|
||||
```
|
||||
# Flask secret key
|
||||
SECRET_KEY=
|
||||
@@ -34,6 +36,7 @@ Aktienbot API
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
--name aktienbot_api \
|
||||
@@ -48,4 +51,5 @@ docker run -d \
|
||||
--restart unless-stopped \
|
||||
registry.flokaiser.com/aktienbot/api:latest
|
||||
```
|
||||
|
||||
or load environment variables from file by using `--env-file <filename>`
|
@@ -4,21 +4,19 @@ __credits__ = ["Florian Kaiser", "Florian Kellermann", "Linus Eickhof", "Kevin P
|
||||
__license__ = "GPL 3.0"
|
||||
__version__ = "1.0.0"
|
||||
|
||||
from flask import current_app
|
||||
from apiflask import APIFlask
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from flask_cors import CORS
|
||||
|
||||
from app.blueprints.keyword import keyword_blueprint
|
||||
from app.blueprints.portfolio import portfolio_blueprint
|
||||
from app.blueprints.shares import shares_blueprint
|
||||
from app.blueprints.share_price import share_price_blueprint
|
||||
from app.blueprints.transactions import transaction_blueprint
|
||||
from app.blueprints.shares import shares_blueprint
|
||||
from app.blueprints.telegram import telegram_blueprint
|
||||
from app.blueprints.transactions import transaction_blueprint
|
||||
from app.blueprints.user import users_blueprint
|
||||
from app.helper_functions import hash_password
|
||||
from app.models import *
|
||||
from dotenv import load_dotenv
|
||||
from flask import current_app
|
||||
from flask_cors import CORS
|
||||
|
||||
|
||||
def create_app(config_filename=None):
|
||||
|
@@ -4,10 +4,9 @@ __credits__ = ["Florian Kaiser", "Florian Kellermann", "Linus Eickhof", "Kevin P
|
||||
__license__ = "GPL 3.0"
|
||||
__version__ = "1.0.0"
|
||||
|
||||
from flask import current_app
|
||||
|
||||
import jwt
|
||||
from apiflask import HTTPTokenAuth
|
||||
from flask import current_app
|
||||
|
||||
auth = HTTPTokenAuth()
|
||||
|
||||
|
@@ -7,12 +7,11 @@ __version__ = "1.0.0"
|
||||
import os
|
||||
|
||||
from apiflask import APIBlueprint, abort
|
||||
|
||||
from app.auth import auth
|
||||
from app.db import database as db
|
||||
from app.helper_functions import make_response, get_email_or_abort_401
|
||||
from app.auth import auth
|
||||
from app.schema import KeywordResponseSchema, KeywordSchema, DeleteSuccessfulSchema
|
||||
from app.models import Keyword
|
||||
from app.schema import KeywordResponseSchema, KeywordSchema, DeleteSuccessfulSchema
|
||||
|
||||
keyword_blueprint = APIBlueprint('keyword', __name__, url_prefix='/api')
|
||||
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
|
||||
|
@@ -15,9 +15,9 @@ SECRET_KEY = os.getenv('SECRET_KEY', 'secret string')
|
||||
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://" + os.getenv('MYSQL_USER') + ":" + os.getenv('MYSQL_PASSWORD') + "@" + os.getenv('MYSQL_HOST') + ":" + os.getenv('MYSQL_PORT', '3306') + "/" + os.getenv('MYSQL_NAME', 'aktienbot')
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False # Avoids SQLAlchemy warning
|
||||
SQLALCHEMY_ENGINE_OPTIONS = {
|
||||
'pool_size': 10,
|
||||
'pool_recycle': 60,
|
||||
'pool_pre_ping': True
|
||||
'pool_size': 10,
|
||||
'pool_recycle': 60,
|
||||
'pool_pre_ping': True
|
||||
}
|
||||
|
||||
# openapi/Swagger config
|
||||
|
@@ -15,8 +15,8 @@ SECRET_KEY = os.getenv('SECRET_KEY', 'secret string')
|
||||
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://" + os.getenv('MYSQL_USER') + ":" + os.getenv('MYSQL_PASSWORD') + "@" + os.getenv('MYSQL_HOST') + ":" + os.getenv('MYSQL_PORT', '3306') + "/" + os.getenv('MYSQL_NAME', 'aktienbot_test')
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False # Avoids SQLAlchemy warning
|
||||
SQLALCHEMY_ENGINE_OPTIONS = {
|
||||
'pool_size': 100,
|
||||
'pool_recycle': 240 # 4 minutes
|
||||
'pool_size': 100,
|
||||
'pool_recycle': 240 # 4 minutes
|
||||
}
|
||||
|
||||
# openapi/Swagger config
|
||||
|
@@ -6,9 +6,8 @@ __version__ = "1.0.0"
|
||||
|
||||
import pytest
|
||||
from app import create_app, db
|
||||
from app.models import User, Transaction, Keyword, Share
|
||||
|
||||
from app.helper_functions import hash_password
|
||||
from app.models import User, Transaction, Keyword, Share
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
|
@@ -8,6 +8,7 @@ __version__ = "1.0.0"
|
||||
This file (test_keyword.py) contains the functional tests for the `keyword` blueprint.
|
||||
"""
|
||||
import json
|
||||
|
||||
from tests.functional.helper_functions import get_token
|
||||
|
||||
|
||||
|
@@ -8,6 +8,7 @@ __version__ = "1.0.0"
|
||||
This file (test_portfolio.py) contains the functional tests for the `portfolio` blueprint.
|
||||
"""
|
||||
import json
|
||||
|
||||
from tests.functional.helper_functions import get_token
|
||||
|
||||
|
||||
|
@@ -8,6 +8,7 @@ __version__ = "1.0.0"
|
||||
This file (test_share.py) contains the functional tests for the `share` blueprint.
|
||||
"""
|
||||
import json
|
||||
|
||||
from tests.functional.helper_functions import get_token
|
||||
|
||||
|
||||
|
@@ -8,6 +8,7 @@ __version__ = "1.0.0"
|
||||
This file (test_telegram.py) contains the functional tests for the `telegram` blueprint.
|
||||
"""
|
||||
import json
|
||||
|
||||
from tests.functional.helper_functions import get_token
|
||||
|
||||
|
||||
|
@@ -8,6 +8,7 @@ __version__ = "1.0.0"
|
||||
This file (test_transaction.py) contains the functional tests for the `transaction` blueprint.
|
||||
"""
|
||||
import json
|
||||
|
||||
from tests.functional.helper_functions import get_token
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user