0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Flaskアプリを作る際の自己流最低限構築

Posted at

初めに

Flaskでアプリを作ろうとして毎回何が必要だったか見直すのが面倒くさいのでQiitaにまとめておきます!(最初の記事投稿がこれでいいのだろうか,,,)

!Flaskをインストールしているの前提です

ディレクトリ構造

root
├─templates
│ └─index.html
│─static
│ └─style.css
└─app.py

app.py

Flaskアプリの起動、ルート処理など

app.py
from flask import Flask, render_template

app = Flask(__name__)

@app.route("/", methods=["GET"])
def index():
    return render_template("index.html")

if __name__ == "__main__":
    app.debug=True
    app.run(host="localhost", port=5000)

index.html

indedx.html
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport">
    <title>title</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
    <link rel="stylesheet" href="{{url_for('static',filename='style.css')}}">
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16"></script>
</head>
<body>
    
    <div class="m-5">
        <p class="display-1">Hello World</p>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
    
</body>
</html>

style.css

style.css
*{
    margin:0px;
    padding:0px;
}

終わりに

最低限なのでSQLなどは別途追加していくって感じです。また、ほかの人と違う部分が多少あるかもしれないです。
今回がQita初投稿ですがこれからQiitaの記事をどんどん出していこうと思うのでお願いします!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?