Skip to content

Commit 042a160

Browse files
authored
Merge pull request microsoft#2 from Microsoft/kraigb-issue001
Updates per Adrian
2 parents 7b7d6cf + 2b33f13 commit 042a160

File tree

18 files changed

+74
-65
lines changed

18 files changed

+74
-65
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"request": "launch",
6565
"module": "flask",
6666
"env": {
67-
"FLASK_APP": "HelloFlask/app.py"
67+
"FLASK_APP": "hello_app/app.py"
6868
},
6969
"args": [
7070
"run",
@@ -122,4 +122,4 @@
122122
]
123123
}
124124
]
125-
}
125+
}

HelloFlask/app.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

HelloFlask/templates/about.html

Lines changed: 0 additions & 4 deletions
This file was deleted.

HelloFlask/templates/contact.html

Lines changed: 0 additions & 4 deletions
This file was deleted.

HelloFlask/templates/hello_there.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

HelloFlask/templates/home.html

Lines changed: 0 additions & 4 deletions
This file was deleted.

HelloFlask/views.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
This sample contains the completed program from the tutorial, [Using Flask in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-flask). Intermediate steps are not included.
2+
3+
Contributions to the sample are welcome. When submitting changes, also consider submitting matching changes to the tutorial, the source file for which is [tutorial-flask.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-flask.md).
4+
15

26
# Contributing
37

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from flask import Flask
2-
app = Flask(__name__)
2+
app = Flask(__name__)

hello_app/app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from hello_app import app
2+
from hello_app import views
3+
4+
# Time-saver: output a URL to the VS Code terminal so you can easily Ctrl+click to open a browser
5+
# print('http://127.0.0.1:5000/hello/VSCode')
File renamed without changes.
File renamed without changes.

hello_app/templates/about.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% extends "layout.html" %}
2+
{% block title %}
3+
About us
4+
{% endblock %}
5+
{% block content %}
6+
<p>About page for the Visual Studio Code Flask tutorial.p>
7+
{% endblock %}

hello_app/templates/contact.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% extends "layout.html" %}
2+
{% block title %}
3+
Contact us
4+
{% endblock %}
5+
{% block content %}
6+
<p>Contact page for the VIsual Studio Code Flask tutorial.p>
7+
{% endblock %}

hello_app/templates/hello_there.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='site.css') }}" />
6+
<title>Hello, Flasktitle>
7+
head>
8+
<body>
9+
<span class="message">Hello there, {{ name }}!span> It's {{ date.strftime("%A, %d %B, %Y at %X") }}.
10+
body>
11+
html>

hello_app/templates/home.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% extends "layout.html" %}
2+
{% block title %}
3+
Home
4+
{% endblock %}
5+
{% block content %}
6+
<p>Home page for the Visual Studio Code Flask tutorial.p>
7+
{% endblock %}

HelloFlask/templates/layout.html renamed to hello_app/templates/layout.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5-
<title>{{ title }}title>
6-
<link rel="stylesheet" type="text/css" href="/static/site.css" />
5+
<title>{% block title %}{% endblock %}title>
6+
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='site.css') }}" />
77
head>
88

99
<body>
@@ -22,4 +22,4 @@
2222
footer>
2323
div>
2424
body>
25-
html>
25+
html>

hello_app/views.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from datetime import datetime
2+
from flask import Flask, render_template
3+
from hello_app import app
4+
5+
@app.route('/')
6+
def home():
7+
return render_template("home.html")
8+
9+
@app.route('/about')
10+
def about():
11+
return render_template("about.html")
12+
13+
@app.route('/contact')
14+
def contact():
15+
return render_template("contact.html")
16+
17+
@app.route('/hello/')
18+
def hello_there(name):
19+
return render_template(
20+
"hello_there.html",
21+
name=name,
22+
date=datetime.now()
23+
)
24+
25+
@app.route('/api/data')
26+
def get_data():
27+
return app.send_static_file('data.json')

0 commit comments

Comments
 (0)