forked from AKAmaestro/python-machine-learning-book
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,575 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from flask import Flask, render_template | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def index(): | ||
return render_template('first_app.html') | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>First app</title> | ||
</head> | ||
<body> | ||
|
||
<div> | ||
Hi, this is my first Flask web app! | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from flask import Flask, render_template, request | ||
from wtforms import Form, TextAreaField, validators | ||
|
||
app = Flask(__name__) | ||
|
||
class HelloForm(Form): | ||
sayhello = TextAreaField('',[validators.DataRequired()]) | ||
|
||
@app.route('/') | ||
def index(): | ||
form = HelloForm(request.form) | ||
return render_template('first_app.html', form=form) | ||
|
||
@app.route('/hello', methods=['POST']) | ||
def hello(): | ||
form = HelloForm(request.form) | ||
if request.method == 'POST' and form.validate(): | ||
name = request.form['sayhello'] | ||
return render_template('hello.html', name=name) | ||
return render_template('first_app.html', form=form) | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
font-size: 2em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% macro render_field(field) %} | ||
<dt>{{ field.label }} | ||
<dd>{{ field(**kwargs)|safe }} | ||
{% if field.errors %} | ||
<ul class=errors> | ||
{% for error in field.errors %} | ||
<li>{{ error }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
</dd> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>First app</title> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> | ||
</head> | ||
<body> | ||
|
||
{% from "_formhelpers.html" import render_field %} | ||
|
||
<div>What's your name?</div> | ||
<form method=post action="/hello"> | ||
|
||
<dl> | ||
{{ render_field(form.sayhello) }} | ||
</dl> | ||
|
||
<input type=submit value='Say Hello' name='submit_btn'> | ||
|
||
</form> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>First app</title> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> | ||
</head> | ||
<body> | ||
|
||
<div>Hello {{ name }}</div> | ||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.