Giter Club home page Giter Club logo

flask-template-minimal's Introduction

Flask Python Basic Template

This is a starter flask template for building web and hybrid desktop apps with support for webview in desktop environment and web backend for mobile environment. There is a build script for desktop pyinstaller.spec using pyinstaller and mobile buildozer.spec using the buildozer package.

This project does not come with any web framework included so you have a fresh project code base with no bloat code. This is intended as a new minimal project template

contributions welcome alt text

Pre-Organised Project Structure

The project's project directory is pre organised for flask development so the developers can just focus on their task

Pre-Optimised Build Script

The build scripts are pre optimised for size and therefore contains a lot of excludes in the build script. This means you need to check the excludes list to remove the packages your using for the project.

Dependencies

This project template contain the required basics such SQLite for database, Flask as the web framework

Configure the project

The recommended way is to use a virtual environment and then install the packages there instead of using system site packages

    python -m venv packages

To activate the virtual environment type the following command

    ./packages/Scripts/activate (if in windows)
    source /packages/bin/activate (if other platform)

To install the project dependies type the following

    pip install -r requirements.txt

To deactive the virtual environment type the following

    deactivate

Preview the project

To start flask app as a desktop web app type the following command

    python main.py

To start flask app as a localhost server type the following command

in windows set FLASK_APP=hello.py in linux export FLASK_APP="hello.py"

    flask run

Android toolchain dependencies

Test to work in Ubuntu 18.04 (64-Bit)

    sudo apt update
    sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config \
    zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev
    pip3 install --user --upgrade cython virtualenv
    export PATH=$PATH:~/.local/bin/

For buildozer related troubleshooting refer https://buildozer.readthedocs.io/en/latest/installation.html

Building the project

Desktop

To build the project in desktop platform (windows, linux, mac, etc), type the following command

    pyinstaller pyinstaller.spec

There is a lot of excludes in the pyinstaller.spec file. Remember to uncomment libraries if your using it

It is recommended not use UPX for reducing the size of the application as it is known to break the vcruntime140.dll used by pyinstaller in windows

Mobile

To build applications in mobile platform you need the linux platform because of some tools used by the toolchain not working in windows. If your in windows then use the windows subsystem for linux to get linux terminal in windows

The first build time will be very long but later on will be cached to make it faster and also there will be a lot to download such as the necessary SDKs, etc

To build the project in mobile platform (android, ios) type the following command

    buildozer android debug run

If errors occur in the android toolchain it is recommended to clean the project using the command buildozer android clean

If you get build errror then go to buildozer.spec file and change pka.fork as kivy or pygame and and also type to change the android branch pka.branch as develop or master. You might need to try these combinations.

Android Logging

To see the logs of your compiled android app enable Developer Mode and enable the USB Debugging option inside it. Then open a terminal and type the following command.

To get the log you need adb (Android Debug Bridge) installed in your system

    adb -d logcat *:S python:D

Type checking

It's a good practice to use type checking in your project. Python supports type annotations. The mypy package can check if the project contains type issues. Run the following command

Remember that type annotations is not strictly required. Which means your project will run just fine without it mypy will only show warning and error messages

    mypy .\source\ --ignore-missing-imports --strict

flask-template-minimal's People

Contributors

aswinmurali-io avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.