# Basic of Flask

### When you create Flask server, make sure to have three items in the project folder.
1. `Static` folder
; Usually, image or CSS files will be stored
2. `Templates` folder
; HTML files will be stored
3. `App.py` file


- Create directory folders named 'templates' and 'static' respectively.
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660914850973/_dqAO0wi9.png align="left")

#### Start with the code below.

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

@app.route('/')
def home():
   return 'This is Home!'

if __name__ == '__main__':
   app.run('0.0.0.0',port=5000,debug=True)
```

<hr>

- Update the code like below and open `http://localhost:5000/`

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

@app.route('/')
def home():
   return '<button>나는 버튼이다</button>'

if __name__ == '__main__':
   app.run('0.0.0.0',port=5000,debug=True)
```
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660915230685/4Qaazu2sQ.png align="left")


- Create a HTML file named `index.html` under `templates` folder.

- write a code like below in `index.html` file.

```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <h1>나의 첫 웹페이지!</h1>
  <button>버튼을 만들자</button>
</body>
</html>
```

- write a code in `app.py` file

```
from flask import Flask, render_template
app = Flask(__name__)

@app.route('/')
def home():
   return render_template('index.html')

if __name__ == '__main__':
   app.run('0.0.0.0',port=5000,debug=True)
```

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660915560561/DqgBZYezv.png align="left")

> it reads and show the HTML file we made. So if you have HTML file and it can be uploaded online in this way!






























