Building RESTful Python Web Services by Gastón C. Hillar
Author:Gastón C. Hillar
Language: eng
Format: mobi, epub
Publisher: Packt Publishing
Published: 2017-12-14T08:48:12+00:00
Setting up a virtual environment with Flask and Flask-RESTful
In Chapter 1, Developing RESTful APIs with Django, we learned that, throughout this book, we were going to work with the lightweight virtual environments introduced in Python 3.4 and improved in Python 3.4. Now, we will follow the steps to create a new lightweight virtual environment to work with Flask and Flask-RESTful. It is highly recommended to read Chapter 1, Developing RESTful APIs with Django, in case you don't have experience with lightweight virtual environments in Python. The chapter includes all the detailed explanations of the effects of the steps we are going to follow.
First, we have to select the target folder or directory for our virtual environment. We will use the following path in the example for macOS and Linux. The target folder for the virtual environment will be the PythonREST/Flask01 folder within our home directory. For example, if our home directory in macOS or Linux is /Users/gaston, the virtual environment will be created within /Users/gaston/PythonREST/Flask01. You can replace the specified path with your desired path in each command, as shown:
~/PythonREST/Flask01
We will use the following path in the example for Windows. The target folder for the virtual environment will be the PythonREST\Flask01 folder within our user profile folder. For example, if our user profile folder is C:\Users\Gaston, the virtual environment will be created within C:\Users\gaston\PythonREST\Flask01. You can replace the specified path with your desired path in each command, as shown:
%USERPROFILE%\PythonREST\Flask01
Open a Terminal in macOS or Linux and execute the following command to create a virtual environment:
python3 -m venv ~/PythonREST/Flask01
In Windows, execute the following command to create a virtual environment:
python -m venv %USERPROFILE%\PythonREST\Flask01
The preceding command doesn't produce any output. Now that we have created a virtual environment, we will run a platform-specific script to activate it. After we activate the virtual environment, we will install packages that will only be available in this virtual environment.
If your Terminal is configured to use the bash shell in macOS or Linux, run the following command to activate the virtual environment. The command also works for the zsh shell:
source ~/PythonREST/Flask01/bin/activate
If your Terminal is configured to use either the csh or tcsh shell, run the following command to activate the virtual environment:
source ~/PythonREST/Flask01/bin/activate.csh
If your Terminal is configured to use either the fish shell, run the following command to activate the virtual environment:
source ~/PythonREST/Flask01/bin/activate.fish
In Windows, you can run either a batch file in the Command Prompt or a Windows PowerShell script to activate the virtual environment. If you prefer the Command Prompt, run the following command in the Windows command line to activate the virtual environment:
%USERPROFILE%\PythonREST\Flask01\Scripts\activate.bat
If you prefer the Windows PowerShell, launch it and run the following commands to activate the virtual environment. However, note that you should have the scripts execution enabled in Windows PowerShell to be able to run the script:
cd $env:USERPROFILE PythonREST\Flask01\Scripts\Activate.ps1
After you activate the virtual environment, the Command Prompt will display the virtual environment root folder name, enclosed in parenthesis, as a prefix for the default prompt, to remind us that we are working in the virtual environment.
Download
Building RESTful Python Web Services by Gastón C. Hillar.epub
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Ada | Ajax |
Assembly Language Programming | Borland Delphi |
C & C++ | C# |
CSS | Compiler Design |
Compilers | DHTML |
Debugging | Delphi |
Fortran | Java |
Lisp | Perl |
Prolog | Python |
RPG | Ruby |
Swift | Visual Basic |
XHTML | XML |
XSL |
Hello! Python by Anthony Briggs(9911)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9794)
The Mikado Method by Ola Ellnestam Daniel Brolund(9775)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8292)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7775)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7758)
Grails in Action by Glen Smith Peter Ledbrook(7693)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Windows APT Warfare by Sheng-Hao Ma(6782)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6509)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6377)
Kotlin in Action by Dmitry Jemerov(5061)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4315)
Functional Programming in JavaScript by Mantyla Dan(4037)
Solidity Programming Essentials by Ritesh Modi(3975)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3761)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3704)
The Ultimate iOS Interview Playbook by Avi Tsadok(3679)
