Skip to content

Opinionated way to create a new flask python project - TO BE REFINED

License

Notifications You must be signed in to change notification settings

jecnua/python-skeleton

Repository files navigation

Python module skeleton - TO BE REFINED

License: MIT python-3

TO_BE_REFINED

DISCLAIMER: This module has been created in a hurry so it not at the same standards of the others.

This module will create a python3 flask project (with docker and testing).

Usage

You will need to call the script passing as a parameter the new project path:

./script.sh <path-to-dir>

For example:

./script.sh /tmp/jecnua-new-project

Test

To run the python app locally (not in docker):

pipenv install
export FLASK_APP=src/app.py
FLASK_APP=src/app.py pipenv run flask run

Build

Build and run docker:

docker build . -t python-test:latest
docker rm -f python-test
docker run --rm --name python-test -d -p 5000:5000 python-test:latest

Notes

How to build url with variables:

Different error code:

Validate https://pythonhosted.org/Flask-Inputs/

Ignored for now

Validation

input_recieved = request.get_json(force=True)

This will return malformed if it's empty or not json.

app.logger.error(request.is_json) # Too strict as it's not specified

Notes

Limitation of cli and endpoint.

TODO

  • Add a version for lambdas
  • Add travis
  • Add acqua docker scan
  • Allow to choose the project name
  • Import all new learning