Skip to content

Commit fd49556

Browse files
committed
Play with flask
1 parent 35bae03 commit fd49556

File tree

13 files changed

+545
-1
lines changed

13 files changed

+545
-1
lines changed

55-robots.sh

100755100644
File mode changed.

flask/30-flask.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Install Flask
4+
poetry add 'flask==*'
5+
6+
# Create the main application file
7+
cat > "app.py" <<EOF
8+
from flask import Flask
9+
10+
11+
app = Flask(__name__)
12+
13+
14+
@app.route('/')
15+
def index():
16+
return 'Hello, World!'
17+
18+
19+
if __name__ == '__main__':
20+
app.run()
21+
EOF
22+
23+
# Create test file in root
24+
cat > "app_tests.py" <<EOF
25+
from app import app
26+
27+
28+
def test_hello():
29+
client = app.test_client()
30+
response = client.get('/')
31+
assert response.data == b'Hello, World!'
32+
EOF
33+
34+
# Basic git setup
35+
git add --all
36+
git commit -m "Initialize minimal Flask application"

flask/everything.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -e # Exit immediately if a command exits with a non-zero status
3+
set -o pipefail # Prevent errors in a pipeline from being masked
4+
5+
# Get the directory path of the current script
6+
script_dir=$(dirname "$0")
7+
8+
# Execute the initialization scripts
9+
source "$script_dir/../10-git.sh"
10+
source "$script_dir/../20-poetry.sh"
11+
source "$script_dir/../21-flake.sh"
12+
source "$script_dir/../22-isort.sh"
13+
source "$script_dir/../23-pytest.sh"
14+
source "$script_dir/30-flask.sh"

flask/example.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
source ../example.sh

flask/example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__/

flask/example/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# example
2+
3+
## Python deps
4+
5+
This project uses Poetry for dependency management. To install the dependencies, run:
6+
7+
poetry install
8+
9+
To activate the virtual environment, run:
10+
11+
poetry shell

flask/example/app.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from flask import Flask
2+
3+
4+
app = Flask(__name__)
5+
6+
7+
@app.route('/')
8+
def index():
9+
return 'Hello, World!'
10+
11+
12+
if __name__ == '__main__':
13+
app.run()

flask/example/app_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from app import app
2+
3+
4+
def test_hello():
5+
client = app.test_client()
6+
response = client.get('/')
7+
assert response.data == b'Hello, World!'

flask/example/commits.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
--- Initial commit
3+
4+
--- Initialize Poetry environment
5+
6+
.gitignore | 1 +
7+
README.md | 11 +++++++++++
8+
pyproject.toml | 19 +++++++++++++++++++
9+
3 files changed, 31 insertions(+)
10+
11+
--- Install and configure Flake8 with flake8-pyproject
12+
13+
poetry.lock | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14+
pyproject.toml | 10 ++++++++
15+
2 files changed, 86 insertions(+)
16+
17+
--- Install and configure isort with flake8-isort
18+
19+
poetry.lock | 37 ++++++++++++++++++++++++++++++++++++-
20+
pyproject.toml | 8 ++++++++
21+
2 files changed, 44 insertions(+), 1 deletion(-)
22+
23+
--- Install and configure pytest
24+
25+
poetry.lock | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
26+
pyproject.toml | 4 ++++
27+
2 files changed, 79 insertions(+), 1 deletion(-)
28+
29+
--- Initialize minimal Flask application
30+
31+
app.py | 10 ++++
32+
app_test.py | 6 ++
33+
poetry.lock | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
34+
pyproject.toml | 1 +
35+
4 files changed, 189 insertions(+), 3 deletions(-)

flask/example/poetry.lock

Lines changed: 354 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)