Git Product home page Git Product logo

flask-examples's Introduction

Flask Examples

Example applications for Flask beginners.

Installation

First, you need to clone this repository:

git clone [email protected]:greyli/flask-examples.git

Or:

git clone https://github.com/helloflask/flask-examples.git

Then change into the flask-examples folder:

cd flask-examples

Now, we will need to create a virtual environment and install all the dependencies:

python3 -m venv venv  # on Windows, use "python -m venv venv" instead
. venv/bin/activate   # on Windows, use "venv\Scripts\activate" instead
pip install -r requirements.txt

How to Run a Specific Example Application?

Before run a specific example application, make sure you have activated the virtual enviroment.

For example, if you want to run the Hello application, just execute these commands:

cd hello
flask run

Similarly, you can run HTTP application like this:

cd http
flask run

The applications will always running on http://localhost:5000.

Example Applications Menu

  • Hello (/hello): Say hello with Flask.
  • HTTP (/http): HTTP handing in Flask.
  • Templates (/templates): Templating with Flask and Jinja2.
  • Form (/form): Form handing with Flask-WTF (WTForms), File upload and integrating with Flask-CKEditor, Flask-Dropzone.
  • Database (/database): Database with Flask-SQLAlchemy (SQLAlchemy).
  • Email (/email): Email with Flask-Mail, SendGrid
  • Assets (/assets): Assets profiling with Flask-Assets.
  • Cache (/cache): Cache with Flask-Caching.

Advanced Examples Flask Applications

  • SayHello: A simple message board.
  • Bluelog: A blog engine that supports category and resource management.
  • Albumy: A full-featured photo-sharing social networking.
  • Todoism: A to-do application implements as SPA, it supports i18n and provides web APIs.
  • CatChat: A chat room based on WebSocket.

Contributions

Any contribution is welcome, just fork and submit your PR.

License

This project is licensed under the MIT License (see the LICENSE file for details).

flask-examples's People

Contributors

berdal84 avatar crayxt avatar dependabot[bot] avatar greyli avatar ivall avatar pandermusubi avatar prattweaks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flask-examples's Issues

Upgrade to Python 3.8 for hello program

Here's the last part of the stack trace I think time.clock isn't working for Python 3.8

File "c:\users\rskov\appdata\local\programs\python\python38\lib\site-packages\mako\compat.py", line 145, in
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'

Remove `$ ` from README's commands

Hi,

I just cloned the repository by following the instructions. I am a bit annoyed by the $ character you added at the beginning of each code block. I suggest removing the $ prefix on all lines. This would make it easy to copy-paste, especially for multi-line commands.

EDIT: if the $ is here to express it must be run from a command line, I would suggest writing a small phrase at the beginning, like: "Open your terminal and run the following commands:"

And thanks for the repository, I need to learn about flask, this is a good start to look at your examples.

Error during run with venv (jsmin / use_2to3 is invalid.)

git clone https://github.com/helloflask/flask-examples.git
cd flask-examples
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
...
pip install -r requirements.txt
Looking in indexes: https://pypi.python.org/simple/
Collecting alembic==1.5.8
  Downloading alembic-1.5.8-py2.py3-none-any.whl (159 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 159.6/159.6 KB 1.6 MB/s eta 0:00:00
Collecting blinker==1.4
  Downloading blinker-1.4.tar.gz (111 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 111.5/111.5 KB 7.0 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting click==7.1.2
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.8/82.8 KB 8.3 MB/s eta 0:00:00
Collecting cssmin==0.2.0
  Downloading cssmin-0.2.0.tar.gz (3.2 kB)
  Preparing metadata (setup.py) ... done
Collecting email-validator==1.1.2
  Downloading email_validator-1.1.2-py2.py3-none-any.whl (17 kB)
Collecting flask-assets==0.12
  Downloading Flask-Assets-0.12.tar.gz (22 kB)
  Preparing metadata (setup.py) ... done
Collecting flask-caching==1.7.2
  Downloading Flask_Caching-1.7.2-py2.py3-none-any.whl (27 kB)
Collecting flask-ckeditor==0.4.3
  Downloading Flask_CKEditor-0.4.3-py2.py3-none-any.whl (4.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.9/4.9 MB 2.7 MB/s eta 0:00:00
Collecting flask-debugtoolbar==0.10.1
  Downloading Flask_DebugToolbar-0.10.1-py2.py3-none-any.whl (326 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 326.8/326.8 KB 34.9 MB/s eta 0:00:00
Collecting flask-dropzone==1.5.3
  Downloading Flask_Dropzone-1.5.3-py2.py3-none-any.whl (22 kB)
Collecting flask-mail==0.9.1
  Downloading Flask-Mail-0.9.1.tar.gz (45 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.7/45.7 KB 8.6 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting flask-migrate==2.5.2
  Downloading Flask_Migrate-2.5.2-py2.py3-none-any.whl (13 kB)
Collecting flask-sqlalchemy==2.5.1
  Downloading Flask_SQLAlchemy-2.5.1-py2.py3-none-any.whl (17 kB)
Collecting flask-wtf==0.14.2
  Downloading Flask_WTF-0.14.2-py2.py3-none-any.whl (14 kB)
Collecting flask==1.0
  Downloading Flask-1.0-py2.py3-none-any.whl (97 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.8/97.8 KB 16.4 MB/s eta 0:00:00
Collecting greenlet==1.0.0
  Downloading greenlet-1.0.0.tar.gz (84 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.5/84.5 KB 16.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting itsdangerous==1.1.0
  Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting jinja2==2.11.3
  Downloading Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.7/125.7 KB 21.7 MB/s eta 0:00:00
Collecting jsmin==2.2.2
  Downloading jsmin-2.2.2.tar.gz (12 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in jsmin setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Python 3.10.6

Invalid package

Hi!

requirements.txt lists mako==1.1.13 as a dependency - this version simply doesn't exist on pypi. Works like a charm after changing this to any valid version.
Also, werkzeug is outdated and fails on Python3.9; updating its version to werkzeug==0.15.5 helps.

Cheers,

Preparing metadata (setup.py) error: subprocess-exited-with-error

Can you help me run this project by identifying the part that is wrong?
I tried to set up this example.
When running pip install -r requirements.txt
My output

❯ asdf current
python          3.10.12         /Users/user/helloflask/.tool-versions

# Activated venv

❯ python -V
Python 3.10.12

pip list
Package    Version
---------- -------
pip        23.0.1
setuptools 65.5.0

[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip

❯ pip install -r requirements.txt
Looking in indexes: https://pypi.python.org/simple/
Collecting alembic==1.5.8
  Using cached alembic-1.5.8-py2.py3-none-any.whl (159 kB)
Collecting blinker==1.4
  Using cached blinker-1.4.tar.gz (111 kB)
  Preparing metadata (setup.py) ... done
Collecting click==7.1.2
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting cssmin==0.2.0
  Using cached cssmin-0.2.0.tar.gz (3.2 kB)
  Preparing metadata (setup.py) ... done
Collecting email-validator==1.1.2
  Using cached email_validator-1.1.2-py2.py3-none-any.whl (17 kB)
Collecting flask-assets==0.12
  Using cached Flask-Assets-0.12.tar.gz (22 kB)
  Preparing metadata (setup.py) ... done
Collecting flask-caching==1.7.2
  Using cached Flask_Caching-1.7.2-py2.py3-none-any.whl (27 kB)
Collecting flask-ckeditor==0.4.3
  Using cached Flask_CKEditor-0.4.3-py2.py3-none-any.whl (4.9 MB)
Collecting flask-debugtoolbar==0.10.1
  Using cached Flask_DebugToolbar-0.10.1-py2.py3-none-any.whl (326 kB)
Collecting flask-dropzone==1.5.3
  Using cached Flask_Dropzone-1.5.3-py2.py3-none-any.whl (22 kB)
Collecting flask-mail==0.9.1
  Using cached Flask-Mail-0.9.1.tar.gz (45 kB)
  Preparing metadata (setup.py) ... done
Collecting flask-migrate==2.5.2
  Using cached Flask_Migrate-2.5.2-py2.py3-none-any.whl (13 kB)
Collecting flask-sqlalchemy==2.5.1
  Using cached Flask_SQLAlchemy-2.5.1-py2.py3-none-any.whl (17 kB)
Collecting flask-wtf==0.14.2
  Using cached Flask_WTF-0.14.2-py2.py3-none-any.whl (14 kB)
Collecting flask==1.0
  Using cached Flask-1.0-py2.py3-none-any.whl (97 kB)
Collecting greenlet==1.0.0
  Using cached greenlet-1.0.0.tar.gz (84 kB)
  Preparing metadata (setup.py) ... done
Collecting itsdangerous==1.1.0
  Using cached itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting jinja2==2.11.3
  Using cached Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
Collecting jsmin==2.2.2
  Using cached jsmin-2.2.2.tar.gz (12 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in jsmin setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip

❯ pip list
Package    Version
---------- -------
pip        23.0.1
setuptools 65.5.0

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.