flask
11659 ワード
3/30
フラスコはホームページを印刷する工場です.


ビジュアルスタジオコードにフラスコをインストールします.実行http://127.0.0.1:5000
またはインターネット経由で↓
glitch.com-会員入力-ログイン後フラスコをスキャンして実行
https://glitch.com/edit/#!/utopian-olivine-detail?path=tc.py%3A59%3A0
start.sh-python 3に変更を保存して続行
ルート
繰り返し文で...f stringを使用して、文字列を変数とともに書き込むことができます.前に引用符を使うと引用符を使う
int:整数で出力
重複コードをテンプレート()、getContents()にパッケージ化
ユーザーが入力したコンテンツをサーバに送信するフォームタグ
ルーティングの選択からソースコードの作成方法まで理解しにくい.ううう
https://www.dropbox.com/sh/sepjxwyax98bsvp/AADs1PmVYLN0MKKSTRulpvQua?dl=0(フラスコ先行学習ページ)
https://glitch.com/edit/#!/flask---daegu-ai-school(李戈穎講師のリアルタイム故障)
https://flask.palletsprojects.com/en/2.1.x/(フラスコ取り付けページ)
難しすぎて・・・見ても見ても、なぜか分からない...ううう
このような状況ではよく協力してこそ運行できますよああ...
学習の内容
フラスコはホームページを印刷する工場です.



またはインターネット経由で↓

glitch.com-会員入力-ログイン後フラスコをスキャンして実行
https://glitch.com/edit/#!/utopian-olivine-detail?path=tc.py%3A59%3A0

start.sh-python 3に変更を保存して続行


ルート




繰り返し文で...f stringを使用して、文字列を変数とともに書き込むことができます.前に引用符を使うと引用符を使う


int:整数で出力


重複コードをテンプレート()、getContents()にパッケージ化


ユーザーが入力したコンテンツをサーバに送信するフォームタグ

from flask import Flask
app = Flask(__name__)
topics = [
{"id":1, "title":"html", "body":"html is ...."},
{"id":2, "title":"css", "body":"css is ...."},
{"id":3, "title":"js", "body":"js is ...."}
]
def template(content):
liTags = ''
for topic in topics:
liTags = liTags + f'<li><a href="/read/{topic["id"]}/">{topic["title"]}</a></li>'
return f'''
<html>
<body>
<h1><a href="/">WEB</a></h1>
<ol>
{liTags}
</ol>
{content}
<ul>
<li><a href="/create/">create</a></li>
</ul>
</body>
</html>
'''
@app.route("/")
def index():
return template('<h2>Welcome</h2>Hello, WEB!')
@app.route("/read/<int:id>/")
def read(id):
title = ''
body = ''
for topic in topics :
if topic['id'] == id:
title = topic['title']
body = topic['body']
break;
return template(f'<h2>{title}</h2>{body}')
@app.route('/create/')
def create():
content = '''
<form action="/create/">
<p><input type="text" name="title" placeholder="title"></p>
<p><textarea name="body" placeholder="body"></textarea></p>
<p><input type="submit" value="create"></p>
</form>
'''
return template(content)
@app.route('/update/')
def update():
return 'Update'
app.run()
学習中の難点
ルーティングの選択からソースコードの作成方法まで理解しにくい.ううう
ソリューションの作成
https://www.dropbox.com/sh/sepjxwyax98bsvp/AADs1PmVYLN0MKKSTRulpvQua?dl=0(フラスコ先行学習ページ)
https://glitch.com/edit/#!/flask---daegu-ai-school(李戈穎講師のリアルタイム故障)
https://flask.palletsprojects.com/en/2.1.x/(フラスコ取り付けページ)
学習の心得.
難しすぎて・・・見ても見ても、なぜか分からない...ううう
このような状況ではよく協力してこそ運行できますよああ...
Reference
この問題について(flask), 我々は、より多くの情報をここで見つけました https://velog.io/@nomadgogo/flaskテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol