[PYTHON] I was addicted to Flask on dotCloud

I was wondering where to deploy the application made with Flask, and it is written in Official deployment document. I decided to try it with Heroku and dotCloud. So, Heroku didn't have much addiction to Flask in Documentation, but I was addicted to dotCloud, so I made a note. Oh, it's not that Heroku is good and dotCloud is bad! Rather, I want to operate it with dotCloud.

The documentation on the Flask side

Deploying WSGI on dotCloudwithFlask-specificnotes

That's why Flask is arranged for WSGI with basic WSGI. While reading the former, the actual work feels like the latter.

However, since I did Heroku first, it wasn't configured to be written in the package __init__.py. Create a directory of packages and move ʻapp.py-like things to init.py. Then write wsgi.py. If you didn't specify approot in dotcloud.yml, put wsgi.py` in the root. Please note that this is different from the former document. Well, even the former is at the beginning

Your WSGI callable should be named “application”, be located in a “wsgi.py” file, itself located at the top directory of the service.

Although it is written, approot is specified in the subsequent procedure explanation.

So, it starts to work, but with this, the sample stops. The app I was trying to deploy used the twitter API, so I have to put the key. I definitely don't want to put the key in SCM. On Heroku, I set it with config: add. You can now read it from os.environ.

For dotCloud, do var set. The method of specification was almost the same as Heroku, so the code remains the same ... but it doesn't work at all! If you read the documentation carefully, you need to read environment.json. I rewrote the code to read from here.

With this, I was able to bring it to the point where it could move. I haven't touched the database-related part yet.

I feel like I'm not so addicted to it, but he solved the addiction.

dotcloud logs appname.www

The most important point is that it was difficult because I didn't know at first. I found out that there was heroku logs in Heroku's Python Tutorial, but it seems that dotCloud didn't have it, so I have to find it myself. had. That's the Consulting Logs (http://docs.dotcloud.com/guides/logs/) in Platform Guides to the left of Documentation. It's been a lot of progress since I found this. In fact, when I ran it without setting environment variables and got an error, it took me a while without knowing the cause. When I look at the log, it feels like that. If you get stuck, look at the log!

Recommended Posts

I was addicted to Flask on dotCloud
I was addicted to trying logging.getLogger in Flask 1.1.x
I was addicted to multiprocessing + psycopg2
I was addicted to pip install mysqlclient
What I was addicted to Python autorun
A note I was addicted to when making a beep on Linux
[Introduction to json] No, I was addicted to it. .. .. ♬
Two things I was addicted to building Django + Apache + Nginx on Windows
I was addicted to running tensorflow on GPU with NVIDIA driver 440 + CUDA 10.2
A story I was addicted to trying to install LightFM on Amazon Linux
I was addicted to not being able to use Markdown on pypi's long_description
I was addicted to scraping with Selenium (+ Python) in 2020
A story that I was addicted to at np.where
Summary of points I was addicted to running Selenium on AWS Lambda (python)
What I was addicted to when using Python tornado
After implementing Watson IoT Platform application in Flask, I was addicted to MQTT connection
[IOS] GIF animation with Pythonista3. I was addicted to it.
What I was addicted to when migrating Processing users to Python
[Fixed] I was addicted to alphanumeric judgment of Python strings
Preparing to run Flask on EC2
Memo (March 2020) that I was addicted to when installing Arch Linux on MacBook Air 11'Early 2015
A story that I was addicted to calling Lambda from AWS Lambda.
What I was addicted to when introducing ALE to Vim for Python
What I was addicted to with json.dumps in Python base64 encoding
Note that I was addicted to sklearn's missing value interpolation (Imputer)
A note I was addicted to when creating a table with SQLAlchemy
I was addicted to confusing class variables and instance variables in Python
Link WAS and FLASK applications on docker
I want to use Linux on mac
I want to develop Android apps on Android
I want to tweet on Twitter with Python, but I'm addicted to it
A story I was addicted to when inserting from Python to a PostgreSQL table
I was addicted to creating a Python venv environment with VS Code
A story I was addicted to trying to get a video url with tweepy
Use Python from Java with Jython. I was also addicted to it.
The file name was bad in Python and I was addicted to import
[Python] I was addicted to not saving internal variables of lambda expressions
I was addicted to trying Cython with PyCharm, so make a note
Log when I was worried that I could not connect to Wi-Fi on Linux
I was able to recurse in Python: lambda
I touched Flask
Notes on Flask
Three things I was addicted to when using Python and MySQL with Docker
AtCoder AGC 041 C --I was addicted to the full search of Domino Quality
I want to do pyenv + pipenv on Windows
I want to log file I / O on Linux
Docker x visualization didn't work and I was addicted to it, so I summarized it!
A note I was addicted to when running Python with Visual Studio Code
A story that I was addicted to when I made SFTP communication with python
I set up TensowFlow and was addicted to it, so make a note
I was soberly addicted to calling awscli from a Python 2.7 script registered in crontab
Note that I was addicted to npm script not passing in the verification environment
It was a life I wanted to OCR on AWS Lambda to locate the characters.
What I was addicted to when combining class inheritance and Joint Table Inheritance in SQLAlchemy
A Python beginner was addicted to registering his own package on PyPI, February 2017 version
I want to transition with a button in flask
I tried to implement Minesweeper on terminal with python
I want to develop an Android application on Android (debugging)
Output log to console with Flask + Nginx on Docker
I want to find a popular package on PyPi
AttributeError: I was addicted to'module' object has no attribute'MyTestCase'