herokuのチュートリアル12
間違っている場所あったら優しく教えてね
herokuチュートリアル11概要
- applicationの一部をcommandで実行することができます.
$ heroku run [コマンド]
herokuのコンソールが使えるらしい.チュートリアルではなく参考に書いてあることをやっってみると.
$ heroku run pwd Running pwd on ⬢ intense-falls-78460... up, run.5085 (Free) /app
pwd(present work directry)カレントディレクトリがどこかを表示してくれた.今度はチュートリアル通りに実行してみる.
$ heroku run python manage.py shell Running python manage.py shell on ⬢ intense-falls-78460... up, run.5693 (Free) /app/.heroku/python/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>. """) Python 3.7.2 (default, Jan 29 2019, 19:41:29) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>>
シェルでの対話が可能になった状態だ.
>>> import requests >>> print(requests.get('http://httpbin.org/status/418').text) -=[ teapot ]=- _...._ .' _ _ `. | ."` ^ `". _, \_;`"---"`|// | ;/ \_ _/ `"""`
表示されました.理解深めるためにもう少し遊んでみましょう.
>>> a = 123 >>> b = 345 >>> c = a + b >>> print (c) 468 >>>
pythonと対話できていることがわかります.(変数を宣言してprintしている)
>>>exit()
exit()コマンドで抜ける(終了する)ことができます
$ heroku run bash Running bash on ⬢ intense-falls-78460... up, run.1495 (Free) ~ $ pwd /app ~ $ ls app.json hello Procfile README.md runtime.txt gettingstarted manage.py Procfile.windows requirements.txt staticfiles ~ $ cd hello/ ~/hello $ ls admin.py __init__.py migrations models.py __pycache__ static templates tests.py views.py ~/hello $ exit exit
チュートリアル通りの動作になりました. Don’t forget to type exit to exit the shell and terminate the dyno. exitするのを忘れるなだそうです.