Upgrade to Pro — share decks privately, control downloads, hide ads and more …

FlaskとYomanでHello World

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

FlaskとYomanでHello World

Avatar for Satoshi Miura

Satoshi Miura

May 30, 2015
Tweet

More Decks by Satoshi Miura

Other Decks in Programming

Transcript

  1. Hello%World from flask import Flask app = Flask(__name__) @app.route("/") def

    hello(): return "Hello World!" if __name__ == "__main__": app.run()
  2. YeomanͷΠϯετʔϧ Node.jsͱnpm͕ඞཁͰ͢ $ npm install -g yo bower grunt-cli $

    yo --version 1.4.6 $ bower --version 1.4.1 $ grunt --version grunt-cli v0.1.13 grunt v0.4.5
  3. Flaskͷͻͳܗ࡞੒ $ mkdir angular-flask $ cd angular-flask $ yo angular-flask

    +-+-+-+-+-+-+-+ +-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+ |a|n|g|u|l|a|r| |f|l|a|s|k| |g|e|n|e|r|a|t|o|r| +-+-+-+-+-+-+-+ +-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+ [?] What is the name of your application? # ΞϓϦ໊Λೖྗ
  4. . ├── Gruntfile.js ├── app ├── bower.json ├── config.py ├──

    db_create.py ├── db_downgrade.py ├── db_migrate.py ├── db_upgrade.py ├── generator.json ├── install.bat ├── install.sh ├── node_modules ├── package.json ├── run.py └── virtualenv.py
  5. app/ ├── __init__.py ├── models │ └── __init__.py ├── routes

    │ ├── __init__.py │ └── index.py ├── static │ ├── css │ ├── index.html │ ├── js │ ├── lib │ └── views └── templates
  6. ը໘Λ௥Ճ͢Δ $ yo angular-flask:entity page1 # page1͸೚ҙͷը໘໊ You called the

    entity subgenerator with the argument page1. # ߲໨໊΍ܕͳͲʹ౴͍͑ͯ͘ Please specify an attribute: [?] What is the name of the attribute? Name [?] What is the type of the attribute? String [?] Enter the minimum length for the String attribute, or hit enter: 1 [?] Enter the maximum length for the String attribute, or hit enter: 10 [?] Is the attribute required to have a value? Yes [?] Would you like to enter another attribute or reenter a previous attribute? Yes [?] What is the name of the attribute? Age [?] What is the type of the attribute? Integer [?] Enter the minimum length for the String attribute, or hit enter: 0 [?] Enter the maximum length for the String attribute, or hit enter: 100 [?] Is the attribute required to have a value? Yes [?] Would you like to enter another attribute or reenter a previous attribute? No
  7. ͔͠͠ཪͰ͸Τϥʔ͕ൃੜɻɻɻ OperationalError: (OperationalError) no such table: page1 u'SELECT page1.id AS

    page1_id, page1."Name" AS "page1_Name", page1."Age" AS "page1_Age" \nFROM page1' () ςʔϒϧ͕ͳ͍Α͏ͳͷͰ࡞੒ $ flask/bin/python db_migrate.py # ը໘Λ௥Ճ͢ΔͨͼʹςʔϒϧΛ࡞੒͢Δ