5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Bottle を使用したウェブアプリケーション(1)

Posted at

このところ javascript を使用する機会が多いのですが、たまに「ちょっとサーバー側にロジックが欲しいな…」と思うことがしばしばあったりします。

サーバーサイドに何らかの処理を行うのであれば、 PHP が何かと都合が良い気がしますけど、個人的使い慣れた C# か Python で何かないかな…ということで、 Bottle を試してみることにしました。

同種のものに CherryPy というのがあり、こちらもかなり軽量なフレームワークだと思っていたのですが、 Bottle はもっと軽量です。(.py ファイルがひとつだけ)

main_cherry.py
import cherrypy

class HelloWorld( object ):

    def index( self ):
        return "Hello World!"

    index.exposed = True

cherrypy.quickstart( HelloWorld() )

こちらが Bottle での記述。

main_bottle.py
from bottle import route, run, template

@route('/')
def index():
    return 'Hello World!'

run( host = 'localhost', port = 8080 )

どちらも充分短いのですが、 Bottle は必要な Python ファイルがひとつだけで動作します。


こちらの記事は水凪工房の記事を Qiita に移植したものです。

5
4
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
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?