File tree 8 files changed +47
-35
lines changed
8 files changed +47
-35
lines changed Original file line number Diff line number Diff line change 64
64
"request" : " launch" ,
65
65
"module" : " flask" ,
66
66
"env" : {
67
- "FLASK_APP" : " runserver.py" ,
68
- "FLASK_ENV" : " development"
67
+ "FLASK_APP" : " HelloFlask/app.py"
69
68
},
70
69
"args" : [
71
- " run"
70
+ " run" ,
71
+ " --no-debugger" ,
72
+ " --no-reload" // Remove to auto-reload modified pages
72
73
]
73
74
},
74
75
{
Original file line number Diff line number Diff line change 1
1
from flask import Flask
2
- app = Flask (__name__ )
3
-
4
- import HelloFlask .views
2
+ app = Flask (__name__ )
Original file line number Diff line number Diff line change
1
+ from HelloFlask import app
2
+ from HelloFlask 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')
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 " />
5
+ < link rel ="stylesheet " type ="text/css " href ="/static/site.css " />
6
+ < title > {{ title }}</ title >
7
+ </ head >
8
+ < body >
9
+ < span class ="message "> {{ message }}</ span > It's {{ date }}.
10
+ </ body >
11
+ </ html >
Original file line number Diff line number Diff line change 1
1
{% extends "layout.html" %}
2
2
{% block content %}
3
- < p > < span class =" message " > {{ message }} </ span > on {{ date }} </ p >
3
+ < p > Home page for the Flask tutorial. </ p >
4
4
{% endblock %}
Original file line number Diff line number Diff line change 1
- from datetime import datetime
1
+ from flask import Flask
2
2
from flask import render_template
3
3
from HelloFlask import app
4
4
5
5
@app .route ('/' )
6
- @app .route ('/home' )
7
- def home ():
8
- now = datetime .now ()
9
-
10
- return render_template (
11
- "home.html" ,
12
- title = 'Hello, Flask' ,
13
- message = "Hello, Flask!" ,
14
- date = now .strftime ("%A, %d %B, %Y at %X" )
15
- )
16
-
17
- @app .route ('/api/data' )
18
- def get_data ():
19
- return app .send_static_file ('data.json' )
6
+ def home ():
7
+ return render_template ("home.html" , title = "Home" )
20
8
21
9
@app .route ('/about' )
22
10
def about ():
@@ -25,3 +13,19 @@ def about():
25
13
@app .route ('/contact' )
26
14
def contact ():
27
15
return render_template ("contact.html" , title = "Contact us" )
16
+
17
+ @app .route ('/hello/<name>' )
18
+ def hello_there (name ):
19
+ from datetime import datetime
20
+ now = datetime .now ()
21
+
22
+ return render_template (
23
+ "hello_there.html" ,
24
+ title = 'Hello, Flask' ,
25
+ message = "Hello there, " + name + "!" ,
26
+ date = now .strftime ("%A, %d %B, %Y at %X" )
27
+ )
28
+
29
+ @app .route ('/api/data' )
30
+ def get_data ():
31
+ return app .send_static_file ('data.json' )
Original file line number Diff line number Diff line change 1
- flask
1
+ click == 6.7
2
+ Flask == 1.0.2
3
+ itsdangerous == 0.24
4
+ Jinja2 == 2.10
5
+ MarkupSafe == 1.0
6
+ Werkzeug == 0.14.1
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments