my changes · pythonkid2/python-tutorial@ef93859 · GitHub
Skip to content

Commit ef93859

Browse files
committed
my changes
1 parent 7069807 commit ef93859

5 files changed

Lines changed: 126 additions & 0 deletions

File tree

advanced/console/calculator.py

Lines changed: 55 additions & 0 deletions

flask/helloWorld/helloworld.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from flask import Flask
2+
3+
app = Flask(__name__) #creating the Flask class object
4+
5+
@app.route('/') #define the default route
6+
def home():
7+
return "hello world!!";
8+
9+
if __name__ =='__main__':
10+
app.run(debug = True)
11+
#try hitting http://localhost:5000

flask/requestResponse/reqres.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from flask import Flask, request, jsonify, render_template
2+
3+
# create the flask app
4+
app = Flask(__name__)
5+
6+
# what html should be loaded as the home page when the app loads?
7+
@app.route('/')
8+
def home():
9+
return render_template('app_frontend.html', prediction_text="")
10+
11+
# define the logic for reading the inputs from the WEB PAGE,
12+
# running the model, and displaying the prediction
13+
@app.route('/predict', methods=['GET','POST'])
14+
def predict():
15+
16+
# get the description submitted on the web page
17+
a_description = request.form.get('description')
18+
return render_template('app_frontend.html', prediction_text=a_description)
19+
20+
# boilerplate flask app code
21+
if __name__ == "__main__":
22+
app.run(debug=True)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<link rel="stylesheet" href="{{ url_for('static', filename='asset_code.css') }}">
6+
</head>
7+
<body>
8+
<h1>Predict Code</h1>
9+
10+
<form action="/predict" method="POST">
11+
<label form="description">Description:</label>
12+
<input type="text" id="description" name="description">
13+
<button type="submit" class=cv_btn>Predict Code</button>
14+
15+
</form>
16+
<br>
17+
<br>
18+
Prediction: {{ prediction_text }}
19+
20+
</body>
21+
</html>

installation/Readme.txt

Lines changed: 17 additions & 0 deletions

0 commit comments

Comments
 (0)