Merge pull request #226 from dbuffel/patch-18

Update 26_python_web.md
This commit is contained in:
Asabeneh 2026-01-15 09:35:37 +02:00 committed by GitHub
commit 47dae826b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -118,11 +118,6 @@ app = Flask(__name__)
def home ():
return '<h1>Welcome</h1>'
@app.route('/about')
def about():
return '<h1>About us</h1>'
if __name__ == '__main__':
# for deployment we use the environ
# to make it work for both production and development
@ -159,7 +154,7 @@ if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=port)
```
Now, we added the about route in the above code. How about if we want to render an HTML file instead of string? It is possible to render HTML file using the function *render_templae*. Let us create a folder called templates and create home.html and about.html in the project directory. Let us also import the *render_template* function from flask.
Now, we added the about route in the above code. How about if we want to render an HTML file instead of string? It is possible to render HTML file using the function *render_template*. Let us create a folder called templates and create home.html and about.html in the project directory. Let us also import the *render_template* function from flask.
### Creating templates
@ -573,4 +568,4 @@ After this step you will get an application like [this](http://thirdaysofpython-
🎉 CONGRATULATIONS ! 🎉
[<< Day 25 ](../25_Day_Pandas/25_pandas.md) | [Day 27 >>](../27_Day_Python_with_mongodb/27_python_with_mongodb.md)
[<< Day 25 ](../25_Day_Pandas/25_pandas.md) | [Day 27 >>](../27_Day_Python_with_mongodb/27_python_with_mongodb.md)