- Get the latest version of python here if you are on Windows.
- pip is included with the latest version of Python
git clone https://github.com/havenfricke/python_webserver.gitcd python_webservercode .- Open the terminal in VS Code
- Run
python3 -m venv server_envto create a python virtual environment - Run
cd server_envto change directory to the created environment - (Linux) Run
source bin/activateor (Windows) run.\Scripts\Activate.ps1to activate the Python environment - Run
pip install fastapito install FastAPI - Run
pip install uvicornto install Uvicorn - Run
pip install dotenvto install dotenv - Run
pip install cryptographyto install cryptography (for dotenv) - Run
pip install sqlalchemyto install SQLAlchemy - Run
pip install aiomysqlto install aiomysql (for SQLAlchemy to un async operations) - Run
pip install pymysqlto install pysql
If you are on Windows the below steps are necessary
-
Switch Interpreters using VS Code shortcut: CTRL + SHIFT + P, type "python: select interpreter"
-
Select the interpreter inside the server_env folder created using
python3 -m venv server_env(You will get import errors if you do not) -
After environment set-up and package installations are complete, run
python main.pyfrom the root directory to start the server.
Controllers: Responsible for incoming traffic, handling files, and authorization.
DB: Responsible for creating a pool connection to the MySQL database cluster and executing MySQL commands (Object relational mapping).
Models: Responsible for modeling known incoming and outgoing data structures, allowing control over what data is included in the application.
Repositories: Responsible for querying necessary MySQL logic related to the application's functionality (Object relational mapping).
Services: Responsible for additional logic necessary for the data to be well received by the repository and database.
Utils: Responsible for additional refactored code dump called upon by the core system.
.env: Responsible for housing and distributing sensitive information throughout the application (hidden during runtime).
Before deploying this server, check main.py, DB/connection.py, and .env to update necessary security policies, environment variables, and configurations