lesson 3 Flashcards

1
Q

What is port forwarding?

A
  • Port forwarding allows us to open pages in our browser from the web server from our virtual machine as if they were being run locally
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is __name__?

A
  • Contains the name of the running application
  • This includes the main application running in python and all the imports.
  • The application is called “__main__”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a decorator?

A
@app.route('/')
def hola():

Calls the hola() function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

urls with variables

A
  • “path/”

- type can be a string, int, path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to render templates?

A
  • import render_template
  • render_template(template.html,variable)
  • {% logical code %}
  • {{ print }}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Make that flask listens to GET and POST

A
  • @app.route(‘restaurants’, methods=[‘GET’,’POST’])

- import request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to redirect to another url?

A

return redirect(url_for())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to add messages that appear after a certain action is done?

A
  • import flash
  • to create the message&raquo_space; flash(“new item created”)
  • get_flashed_messages()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to add css, js or media files to flask?

A
  • Put them in a file called static

- To write the route to the file in the use {{url_for(‘static’, filename=’style.css’)}}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to send JSON info through api’s?

A

1) Create a serialize property in the class MenuItem in database-setup.py
2) import jsonify
3) Add a @app.route and create a function that returns the json

How well did you know this?
1
Not at all
2
3
4
5
Perfectly