Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
38
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

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

あいさつ

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

あとは

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
38
Help us understand the problem. What are the problem?