{"id":854,"date":"2018-03-10T22:58:17","date_gmt":"2018-03-10T22:58:17","guid":{"rendered":"http:\/\/www.codeastar.com\/?p=854"},"modified":"2019-02-10T15:32:28","modified_gmt":"2019-02-10T15:32:28","slug":"flask-easy-web-app-python","status":"publish","type":"post","link":"https:\/\/www.codeastar.com\/flask-easy-web-app-python\/","title":{"rendered":"Easy Weather Forecast Flask Web App with Python"},"content":{"rendered":"

We have tried to code an Easy Weather Forecast Tool<\/a> with Python. Yes, it is fast and easy, but it is just not that convenient to run anything on a command prompt. It is so…. 80s. It would be better if we can make a single-page Flask web app. Then we can run the weather forecast tool on a browser in anywhere. Isn’t it cool? Yeah! Okay, requirement is defined, let’s build our project!<\/p>\n

<\/p>\n

Planning Stage<\/h3>\n

Other than the “single-page web app” requirement, we have another hidden requirement as well, it is “fast and easy” (who doesn’t like fast and easy?). Luckily we are in the Python world, so “fast and easy” is never a miracle to us. Before we go further in our development, let’s use pip<\/a> to install a Python module, the “pipenv<\/a>” for our development environment.<\/p>\n

>pip install pipenv\n<\/pre>\n

Pipenv is not a functional module in our project, but an officially recommended Python packaging tool from\u00a0Python.org<\/a>. We use it before we start our project. The pipenv is a combination of virtual environment and pip. We can create a virtual environment from it, then install \/ uninstall modules within the environment and *automatically*<\/strong>\u00a0maintain the list of the modules.<\/p>\n

Start our project with pipenv<\/h3>\n

After the installation of pipenv, we can set up a directory for our project. Let’s call it “ezw” then (stands for EZ Weather forecast, okay, I admit it, I am a huge wrestling mask, EZW! EZW! EZW!).<\/p>\n

>mkdir ezw\n>cd ezw\n<\/pre>\n

And we initialize a Python 3 environment.<\/p>\n

>pipenv --three\n<\/pre>\n

(Note: for Mac users with Anaconda Python, when you face “dyld: Library not loaded” error, you may need to run Anaconda Distribution of virtualenv first)<\/p>\n

>conda install virtualenv\n<\/pre>\n

[reference: Anaconda’s community group<\/a>]<\/p>\n

When the virtual environment is set,\u00a0we can install following modules with pipenv<\/em>:<\/p>\n