# Flask

## Most basic

```python
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'
```

### Flask Run

Flask run finds trys to find right file to run and loads .env too

```bash
flask run --debug #to run in debug mode
flask run -h 0.0.0.0 -p 80 --debug # to set url
```

*Default of 5000 can cause problems on Mac cuz 5000 is used for control center*

### Flask CLI

```python
# Run `flask createdb` to run this
@app.cli.command()
def createdb():
  # import logging
  # logging.basicConfig()
	# logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)

  from app.models.user import User
  from app.models.question import Question
  print("Created DBBBB")
  db.create_all()
```


---

# 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.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.
