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?

#01 ゼロからPython(Flask)で自作ブログ

Last updated at Posted at 2025-08-05

Flaskでブログアプリを作成する。
まずはHello, Flask!

app.py
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "Hello, Flask!"

if __name__=='__main__':
    app.run(debug=True)

terminalで

$ python app.py

としてブラウザで http://127.0.0.1:5000 にアクセスする。
スクリーンショット 2025-08-05 235322.png

htmlを表示する

app.py
from flask import Flask, render_template  #<-変更

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html') #<-変更

if __name__=='__main__':
    app.run(debug=True)
Templates/index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Blog App</title>
</head>
<body>
    <h1>Hello, Flask!</h1>
</body>
</html>

スクリーンショット 2025-08-06 001246.png

1日目は以上!

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?