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?

表示担当app.pyと動かす担当run.py

Posted at

ディレクトリ構造

pフォルダ
app/
 │ ├templates/
 │ │ └index.html
 │ ├static/
 │ └app.py
 run.py

表示担当 app.py

from flask import Flask,render_template

# Flaskオブジェクトの生成
app = Flask(__name__)


# 「/」へアクセスしたら、"Hello World"表示
@app.route("/")
def hello():
    return "Hello World"


# 「/index」アクセスしたら、「index.html」表示したい
@app.route("/index")
def index():
    return render_template("index.html")

動かす担当 run.py

run.py
from app.app import app

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

NomoduleError: 表示担当と動かす担当にmainが二つ

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

endifがないと表示される

スクリーンショット 2025-04-24 16.21.58.png

問題code
スクリーンショット 2025-04-24 16.23.49.png

変数名がfalseだった時エラー

スクリーンショット 2025-04-24 17.55.57.png

スクリーンショット 2025-04-24 17.56.33.png

スクリーンショット 2025-04-24 17.58.46.png

勉強サイト

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?