Giter Site home page Giter Site logo

flask-sample's Introduction

Flaskサンプルアプリ

アプリケーションの説明

このアプリケーションは

  • サーバーサイド Python Flask
  • クライアントサイド Javascript + ajax で連携するアプリケーションを作る際のサンプルとなっています。 そのままIBM CloudのCloud Foundaryで動くようになっています。

アプリイメージ

前提

IBM Cloud上にアカウントを持っていることが前提です。(ライトアカウントで可)

前提ソフトの導入

次の前提ソフトが導入されていることが前提です。

gitコマンドラインツール (なくても可)
Cloud Foundryコマンドラインツール

注意: Cloud Foundaryのバージョンは最新として下さい。

ソースのダウンロード

Githubからアプリケーションのソースをダウンロードします。
カレントディレクトリのサブディレクトリにソースはダウンロードされるので、あらかじめ適当なサブディレクトリを作り、そこにcdしてから下記のコマンドを実行します。
GITコマンドを使わない場合は、Githubにブラウザからアクセスして、zipファイルをダウンロード後、解凍します。
ダウンロード後、できたサブディレクトリにcdします。

$ cd (適当なサブディレクトリ)
$ git clone https://github.com/makaishi2/flask-sample.git
$ cd flask-sample

CFコマンドでログイン

CFコマンドでIBM Cloud環境にログインします。
ログイン名、パスワードはIBM Cloudアカウント登録で登録したものを利用します。
ログインに成功すると、次のような画面となります。

$ cf api https://api.ng.bluemix.net
$ cf login

アプリケーションのデプロイ

次のコマンドを実行します。 <service_name> はなんでもいいのですが、インターネット上のURLの一部となるので、ユニークな名前を指定します。
(例) wml-kidney-aka

$ cf push <service_name>

アプリケーションのURLと起動

デプロイには数分かかります。デプロイが正常に完了したらアプリケーションを起動できます。
次のURLをブラウザから指定して下さい。

https://<service_name>.mybluemix.net/

アプリケーションを修正する場合

導入手順中、git cloneコマンドでダウンロードしたローカルリポジトリにアプリケーションのソースコードが入っています。
アプリケーションを修正したい場合は、ローカルのソースを修正し、再度 cf push <service_name> コマンドを実行すると、IBM Cloud上のアプリケーションが更新されます。

ローカルで起動する場合

アプリケーションを修正する時は、ローカルでもテストできる方が便利です。そのための手順は以下の通りです。

  • Pythonの導入
    ローカルにPython(v3)を導入する必要があります。 MACの場合は最初から導入済みなのでこの手順は不要です。

* Pythonアプリケーションの導入、実行  
以下のコマンドでアプリケーションの導入、実行を行います。

```sh
$ python server.py

flask-sample's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.