Development environment configuration
1. Choose a directory at will and create a new folder fastapi-back-end-test (the name is arbitrary)
2. Enter fastapi-back-end-test, enter the cmd page after startup. Enter the following command to generate a virtual environment:
E:\github_codes\codes\fastapi-back-end-test>python -m venv venv
Note information: The virtual environment is successfully generated and is serving the current project. If the same environment is shared, there may be situations where the same library requires different versions, etc. The role of the virtual environment is to avoid cross-infection of the environment.
3. Then enter the Scripts folder of the virtual environment, and install the third-party dependency library after starting the virtual environment:
E:\github_codes\codes\fastapi-back-end-test>cd venv
E:\github_codes\codes\fastapi-back-end-test\venv>cd Scripts
E:\github_codes\codes\fastapi-back-end-test\venv\Scripts>activate
(venv) E:\github_codes\codes\fastapi-back-end-test\venv\Scripts>
Note information: After the startup is successful, the (venv) logo appears after the path, which means the startup is successful.
4. After the startup is successful, enter the command to install the required fastapi library:
(venv) E:\github_codes\codes\fastapi-back-end-test\venv\Scripts>pip install fastapi[all] -i https://pypi.douban.com/simple/
Note information: The function of using fastapi[all] is to install all the libraries associated with fastapi, and -i https://pypi.douban.com/simple/ is to specify the Douban installation source, so that the installation will be faster.
5. After the installation is complete, if the python -m pip install --upgrade pip command appears at the bottom, execute the update pip:
(venv) E:\github_codes\codes\fastapi-back-end-test\venv\Scripts>python -m pip install --upgrade pip
Note: It is best to update pip to the latest version. If it is not the latest pip, the installation will fail when using pip to install other libraries. Of course you don't have to update it.
Manually generate project directory
Use vscode to open the project, and the final project project directory is tentatively set as the following screenshot:
src is a manually created directory file, and the newly created __init__.py file is to turn the src directory into a package package. requirements.txt is the name of all the libraries installed by our project. It is mainly used for quick and batch installation of associated libraries when other people use the project.
Later, multiple directories were added to the project directory, and the screenshot is as follows:
crud: mainly places some database operation methods
dependencies: Mainly place some project dependencies, such as token generation and surface encryption, etc.
models: mainly object models for placing some database tables
public: mainly to place some public base classes
routers: mainly to place some interface routes
schemas: mainly to place some model declarations
conf: mainly to place some configuration file reading classes
docs: mainly to place some document descriptions
main.py: is the main entry file
venv: is the python virtual environment
requirements.txt: dependent packages, mainly used for pip batch installation
Automatically generate project directory
The above are the scaffolds that we manually generated. If you feel that there is a gap with your expectations, you can use the official scaffolding.
The officially generated scaffolding includes the front and back ends, and you can see a lot of files. I personally feel that it is not very friendly to beginners.
Finally: The complete software testing video tutorial below has been organized and uploaded, and friends who need it can get it by themselves [Guaranteed 100% free]
Software Testing Interview Documentation
We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.