Skip to main content

This is a Python demo project with Flask

Project description

Python Flask

Dependencies

Mysql

mkdir ./volume

docker run --name flask-demo \
  -e MYSQL_ROOT_PASSWORD=root_pwd \
  -e MYSQL_DATABASE=flask-demo \
  -p 3306:3306 \
  -v $(pwd)/volume/mysql_data:/var/lib/mysql \
  -d mysql:5.7 --character-set-server=utf8mb4

Start project

Pip

# Create Virtualenv
python3 -m venv .venv


# Install denpendencies
python3 -m pip install pytest
python3 -m pip install -r requirements.txt


# Init db and config
flask --app flaskexample init-db


# Start for dev
source .venv/bin/activate
export FLASK_ENV=development
flask [--app flaskexample] run [--debug] [--host=0.0.0.0] [--port=5000]


# Start for prod
source .venv/bin/activate
export FLASK_ENV=production
uwsgi --ini uwsgi.ini
uwsgi --reload logs/uwsgi.pid
uwsgi --stop logs/uwsgi.pid

Poetry

# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$PATH:/root/.local/bin"
#echo PATH="$PATH:/root/.local/bin" >> ~/.bashrc


# Create Virtualenv
poetry config virtualenvs.in-project true
poetry env use `which python3.12`


# Install denpencies
poetry add Flask
poetry install


# Init db and config
flask --app flaskexample init-db


# Start for dev
poetry shell
export FLASK_ENV=development
flask [--app flaskexample] run [--debug --host=0.0.0.0:5000]


# Start for prod
poetry shell
export FLASK_ENV=production
uwsgi --ini uwsgi.ini
uwsgi --reload logs/uwsgi.pid
uwsgi --stop logs/uwsgi.pid

Make the Project Installable

# Build and publish
poetry build
poetry config pypi-token.pypi pypi-token-xxxxx
poetry publish


# Install
# option1
pip install dist/flaskexample-0.1.0-py3-none-any.whl
# option2
pip install flaskexample
# option3
poetry add flaskexample

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flaskexample-0.1.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flaskexample-0.1.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file flaskexample-0.1.1.tar.gz.

File metadata

  • Download URL: flaskexample-0.1.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/24.5.0

File hashes

Hashes for flaskexample-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9b57e27851cbb67be8c2ca1b3cdcc8fe0813d6683e210f2a70e33b0ee37399b1
MD5 e9379be5ec88b081663fcf251728dc87
BLAKE2b-256 84aba947d8fdd42680ff854a12e7f1543c6536b6f851b7638abccc6e7c0fa51b

See more details on using hashes here.

File details

Details for the file flaskexample-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: flaskexample-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/24.5.0

File hashes

Hashes for flaskexample-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7119ccfe5527decd797b69722532a74d49e2751c6806d7a97b70fe502c80f08
MD5 044d8f318441e27b6e705bb0e0c07145
BLAKE2b-256 b39aefa9bef075ad3b264e3f236a1c52b12b4e60394be7ea46982ce29083bcfa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page