# RESPONSES

```python
from flask import Flask, jsonify, make_response

def index():
  #auto sets status code to 200
	return jsonify(data)
	#return 'hi'
  #return make_response("Wrong password", 401)

```

ORRRR

```python
resp = Response(js, status=200, mimetype='application/json')
```

### Render Template

```python
from flask import render_template

@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
    return render_template('hello.html', name=name)
```

Default is template folder

#### Send File

```python
	return send_file('/var/www/PythonProgramming/PythonProgramming/static/images/python.jpg', attachment_filename='python.jpg')

```

## End Early Status Code

```python
from flask import abort
abort(404)

response = jsonify({'message': message})
response.status_code = 400
return response
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openai.gitbook.io/code-cheatsheets/all/python/flask/response.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
