-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
95 lines (87 loc) · 2.11 KB
/
build.sh
File metadata and controls
95 lines (87 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# optional color variables
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
# create a working directory
clear
echo "${red}build: -----> ${green}Starting Flask-createapp...${reset}";
echo -en '\n';
SECONDS=0
echo "${red}build: -----> ${green}Creating directory flaskapp...${reset}";
mkdir flaskapp
cd flaskapp
# build templates
echo -en '\n';
echo "${red}build: -----> ${green}Creating templates directory...${reset}";
echo -en '\n';
mkdir templates
cd templates
touch index.html
echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flask app</title>
</head>
<body>
<h1>Hello World this is my flaskapp</h1>
</body>
</html>' > index.html;
cd ..
# build static files
echo -en '\n';
echo "${red}build: -----> ${green}Creating static directory...${reset}";
echo -en '\n';
mkdir static
cd static
mkdir css
mkdir js
mkdir images
cd ..
# build app.py file
echo -en '\n';
echo "${red}build: -----> ${green}Creating flask app...${reset}";
echo -en '\n';
touch app.py
echo 'from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/hello")
def hello_world():
return "<p>Hello, World!</p>"
if __name__=="__main__":
app.run(debug=True)
' > app.py;
# installs modules
echo -en '\n';
echo "${red}build: -----> ${green}Installing dependencies...${reset}";
echo -en '\n';
pip install flask;
pip freeze > requirements.txt;
echo 'click==8.0.1
colorama==0.4.4
Flask==2.0.1
importlib-metadata==4.8.1
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
typing-extensions==3.10.0.2
Werkzeug==2.0.1
zipp==3.5.0
' > requirements.txt;
echo -en '\n';
echo "${red}build: -----> ${green}Flask app build success...${reset}";
echo -en '\n';
# get elapsed time
duration=$SECONDS
echo "$(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
echo -en '\n';
echo "${red}build: -----> ${green}Running flask app...${reset}";
echo -en '\n';
google-chrome http://127.0.0.1:5000/
python app.py;
clear