35
36

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.

Python+Flask+Herokuで簡単webアプリ

Last updated at Posted at 2015-03-26

あいさつ

Rubyからの視点で色々備忘を綴ります.

pip, pip3

gemみたいなやつ、

python3に同梱されているヤツはpip3

virtualenv

Bundlerみたいなやつ

$ pip3 install virtualenv

bundle init みたいなコマンドでisolatedな環境を作る

$ virtualenv venv

bundle exec みたいなコマンドを打つ

$ source venv/bin/activate

Flask

Sinatraみたいなやつ

$ pip install flask

Gunicorn

webサーバー、unicornみたいなやつ

$ pip install gunicorn

アプリを作り始める

test_appという名前だとします.

$ mkdir test_app; cd test_app


$ touch main.py Procfile
main.py
import os
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello World!'
Procfile
web: gunicorn main:app --log-file=-

起動

$ foreman start

簡単や...

Gemfile.lock的なものを作る

$ pip freeze > requirements.txt

git

$ git init

$ echo 'venv\n*.pyc' > .gitignore

heroku

$ heroku create test-app

$ git push heroku master

$ heroku open

あとは

35
36
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
35
36

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?