質問編集履歴

1

コード記載

2018/10/09 13:26

投稿

panda_fy
panda_fy

スコア13

title CHANGED
File without changes
body CHANGED
@@ -10,4 +10,35 @@
10
10
  Pycharmの何か設定的な問題なのか...
11
11
  もし、設定の問題であるとしたらどうすれば良いのか...
12
12
 
13
- 教えていただけたら幸いです。
13
+ 教えていただけたら幸いです。
14
+
15
+ 以下追加です:
16
+
17
+ ```python
18
+ from flask import Flask, render_template
19
+ from flask_sqlalchemy import SQLAlchemy
20
+
21
+ app: Flask = Flask(__name__)
22
+
23
+
24
+ app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
25
+ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
26
+ db = SQLAlchemy(app)
27
+
28
+
29
+ class Post(db.Model):
30
+ __tablename__ = 'posts'
31
+ id = db.Column(db.Integer, primary_key=True, autoincrement=True)
32
+ title = db.Column(db.Text())
33
+ content = db.Column(db.Text())
34
+
35
+
36
+ @app.route('/')
37
+ def list():
38
+
39
+ message = 'Hello'
40
+ posts = Post.query.all()
41
+
42
+ return render_template('list.html', message = message, posts = posts)
43
+ ```
44
+ よろしくお願いします。