Flask comes packaged with a development web server. You can use this development server to double-check that your code works as expected. To be able to run the Flask development server locally, you need to complete two steps. 1. Set up a virtual environment. 2. Install the flask package. This will create a new virtual environment named venv using the version of Python 3 that you have installed on your system. After executing this command, your prompt will change to indicate that you’re now operating from within the virtual environment. This command fetches all packages listed in requirements.txt from PyPI and installs them in your virtual environment. In this case, the only package installed will be Flask. These two lines tell Python to start Flask’s development server when the script is executed from the command line. It’ll be used only when you run the script locally. When you deploy the code to Google App Engine, a professional web server process, such as Gunicorn, will serve the app instead.
You won’t need to change anything to make this happen. You can now start Flask’s development server and interact with your Python app in your browser. 1. WARNING: This is Flask’s development server, which means you don’t want to use it to serve your code in production. Google App Engine will handle that for you instead. 2. Running on http://127.0.0.1:8080/: This is the URL where you can find your app. It’s the URL for your localhost, which means the app is running on your own computer. Navigate to that URL in your browser to see your code live. C on your keyboard. Follow the instructions and open a browser tab at http://127.0.0.1:8080/. You should see a page displaying the text that your function returns: Congratulations, it's a web app! Note: The URL 127.0.0.1 is also called the localhost, which means that it points to your own computer. The number 8080 that follows after the colon (:) is called the port number.
The port can be thought of as a particular channel, similar to broadcasting a television or radio channel. Running the application on port 8080 means that you can tune in to this port number and receive communication from the development server. Port 8080 is commonly used for local testing, but you could also use a different number. You can use Flask’s development server to inspect any changes that you make to the code of your Python app. The server listens to changes you make in the code and will automatically reload to display them. If your app doesn’t render as you expect it to on the development server, then it won’t work in production either. So make sure that it looks good before you deploy it. Also keep in mind that even if it works well locally, it might not work quite the same once deployed. This is because there are other factors involved when you deploy your code to Google App Engine. However, for a basic app such as the one you’re building in this tutorial, you can be confident that it’ll work in production if it works well locally. Change the return value of index() and confirm that you can see the change reflected in your browser. Play around with it.
They say necessity is the mother of invention, and for Silly Putty, the strange material that ships in an egg and behaves sometimes like a liquid and other times like a solid, necessity came in the form of Imperial Japan. In the early 1940s, as Germany waged war in Europe, the Empire of the Sun invaded rubber-producing countries such as Thailand, Malaysia and the Philippines, cutting off supplies to the West. This was more than a minor issue. Japan's invasion of Southeast Asia threatened, literally, the entire war effort. At a loss, the U.S. War Production Board challenged industrial labs and academic institutions to develop a synthetic rubber that could be used to meet wartime production demands. Collectively, the chemists working on the problem may have achieved one of the greatest successes in the history of science: They produced a general-purpose synthetic rubber known as GR-S, or government rubber-styrene, in sufficient quantity to meet the needs of the U.S. World War II. One of those wrong turns was made by James Wright in the laboratory of General Electric.
Wright mixed boric acid and silicone oil together in the hopes of creating rubber that would make Charles Goodyear proud. General Electric sent Wright's concoction to engineers all over the world, hoping to make something awesome out of the accident. Unfortunately, no one ever discovered a practical use for the "bouncing putty," which seemed destined to fade quietly into history. One man, however, rescued the substance from obscurity. His name was Peter Hodgson, and his vision would eventually lead to Silly Putty, one of the most famous toys in the history of fun and games. In this article, we'll look at the long, strange journey of Silly Putty. We'll also investigate the material's many odd properties -- and the chemistry behind them. Our first order of business: Hodgson's great gamble. World War II had been over for four years, and James Wright's bouncing putty was still in circulation as an invention in search of a practical use.
|