PythonのみでWebアプリが書けるPyWebIO

バナーcoffee Python初心者
スポンサーリンク

おはようございます。ときか姉です♪

Webアプリ開発を行っているのですが、Pythonには色んなやり方がありますよね。私はDashを使っているのですが、DjangoやFlaskが主流みたいですね。

そんな中、ものすごく簡単にWebアプリが書けるフーレムワークがTwitterで紹介されていました。PyWebIOです。

さっそく、試してみました。

pip install pywebio # pipでpywebioのインストール

test.pyファイルに以下の二行を記述

python test.py # 実行

ものすごく簡単です。

公式ドキュメントにあるBMI計算アプリ

from pywebio.input import input, FLOAT
from pywebio.output import put_text

def bmi():
   height = input("Input your height(cm):", type=FLOAT)
   weight = input("Input your weight(kg):", type=FLOAT)

   BMI = weight / (height / 100) ** 2

   top_status = [(16, 'Severely underweight'), (18.5, 'Underweight'),
                 (25, 'Normal'), (30, 'Overweight'),
                 (35, 'Moderately obese'), (float('inf'), 'Severely obese')]

   for top, status in top_status:
       if BMI <= top:
           put_text('Your BMI: %.1f. Category: %s' % (BMI, status))
           break

if __name__ == '__main__':
   bmi()

*身長と体重を入力するとBMIを求めてくれます。

まだまだ日本語の情報が少ないですし、現時点ではどこまでできて何ができないのかはわかりません。ですが、HTMLやJavascriptとか聴いてウェブアプリは敷居が高いと敬遠していた方が、お試しで触れてみるのにはとってもいいと思いますよ♪

より詳細な使い方は以下の公式ドキュメント:

♪♪♪Have a nice coding day♪♪♪

[コーディング時は↓のゲーミングチェア使ってます♪]

[トレード口座開設はコチラ↓]

コメント

タイトルとURLをコピーしました

Fatal error: Uncaught JSMin_UnterminatedStringException: JSMin: Unterminated String at byte 791: "必要なのはPythonの知識だけ!アプリが簡単に書けちゃうPyWebIO。 in /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php:214 Stack trace: #0 /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php(152): JSMin->action(1) #1 /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php(86): JSMin->min() #2 /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(257): JSMin::minify('\n{\n "@context"...') #3 [internal function]: AO_Minify_HTML->_removeScriptCB(Array) #4 /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(108): preg_replace_callback('/(\\s*)(<script\\...', Array, '<!doctype html>...') #5 /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/external/php/ao-minify-html.php(47): AO_Minify_HTML->process() #6 /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/autoptimizeHTML.php(105): AO_Minify_HTML::minify('<!doctype html>...', Array) #7 /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/autoptimizeMain.php(592): autoptimizeHTML->minify() #8 [internal function]: autoptimizeMain->end_buffering('<!doctype html>...', 9) #9 /home/tokikaneesan/tokikaneesan.com/public_html/wp-includes/functions.php(5420): ob_end_flush() #10 /home/tokikaneesan/tokikaneesan.com/public_html/wp-includes/class-wp-hook.php(324): wp_ob_end_flush_all('') #11 /home/tokikaneesan/tokikaneesan.com/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #12 /home/tokikaneesan/tokikaneesan.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #13 /home/tokikaneesan/tokikaneesan.com/public_html/wp-includes/load.php(1270): do_action('shutdown') #14 [internal function]: shutdown_action_hook() #15 {main} thrown in /home/tokikaneesan/tokikaneesan.com/public_html/wp-content/plugins/autoptimize/classes/external/php/jsmin.php on line 214