1.download and install pycharm then create project(reference.
2.activate virtual environment.
3.install existing dependencies.
4.perform crud operationreference.
5.run project
How to run project in different frame work
How to install existing dependencies in different framework
How to Activate Virtual Environment in different framework
ERROR: If psycho module not installed
How to run project in different frame work
FAST API:
Install Dependencies
:
Ensure that you have FastAPI and a server like uvicorn installed:
pip install fastapi[all]
Run the Project
:
You typically run a FastAPI project using uvicorn:
uvicorn main:app --reload
main is the name of the Python file (e.g., main.py).
app is the name of the FastAPI instance in that file (app = FastAPI()).
--reload is an optional flag that automatically reloads the server when you make changes to the code.
USING GUI
GO main menu click 3 bar===>RUN===>run fast api project
FLASK:
flask run
GO main menu click 3 bar===>RUN===>rerun flask server project
another way
another way
right click python file--> click run util.py option
Install Flask
Install Flask:
Make sure Flask is installed:
pip install flask
Set the Flask App Environment Variable:
You need to tell Flask which file to run. For example, if your main file is app.py:
On Windows
:
set FLASK_APP=app.py
On macOS/Linux
:
export FLASK_APP=app.py
Django:
python manage.py runserver
To run the server on a different port, specify it after the runserver command
:
python manage.py runserver 8080
How to install existing dependencies in different framework
pip list: Gives an overview of all installed packages in a summarized list.
pip show: Provides detailed information for a specific package.
pip show <package_name>
pip show Flask
FAST API:
first run command pip list
To install the listed dependencies, you can create a requirements.txt file with the specific versions of the packages and then use pip to install them.
- Create a requirements.txt file First, create a requirements.txt file in your project directory and add the following content:
Package Version
annotated-types 0.7.0
anyio 4.4.0
blinker 1.8.2
click 8.1.7
colorama 0.4.6
fastapi 0.112.1
Flask 3.0.3
Flask-SQLAlchemy 3.1.1
greenlet 3.0.3
h11 0.14.0
idna 3.7
itsdangerous 2.2.0
Jinja2 3.1.4
MarkupSafe 2.1.5
pip 23.2.1
psycopg2 2.9.9
psycopg2-binary 2.9.9
pydantic 2.8.2
pydantic_core 2.20.1
sniffio 1.3.1
SQLAlchemy 2.0.32
starlette 0.38.2
typing_extensions 4.12.2
uvicorn 0.30.6
Werkzeug 3.0.3
- Install the Dependencies Once you have created the requirements.txt file, you can install all the dependencies by running the following command in your terminal:
pip install -r requirements.txt
This command will install all the listed packages with the specified versions.
- Verify Installation After the installation, you can verify that the packages are installed by running:
pip list
This should display all the installed packages along with their versions, matching those specified in the requirements.txt file.
Additional Notes:
- Ensure that you are working within the correct Python environment (e.g., a virtual environment) when installing these packages to avoid conflicts with other projects.
- If any package installation fails, you might need to resolve specific dependencies or install them individually .
FLASK:
Same process follow in what i followed in fastapi
Package Version
----------------- -------
annotated-types 0.7.0
anyio 4.4.0
blinker 1.8.2
click 8.1.7
colorama 0.4.6
fastapi 0.112.1
Flask 3.0.3
Flask-SQLAlchemy 3.1.1
greenlet 3.0.3
h11 0.14.0
idna 3.7
itsdangerous 2.2.0
Jinja2 3.1.4
MarkupSafe 2.1.5
pip 23.2.1
psycopg2 2.9.9
psycopg2-binary 2.9.9
pydantic 2.8.2
pydantic_core 2.20.1
sniffio 1.3.1
SQLAlchemy 2.0.32
starlette 0.38.2
typing_extensions 4.12.2
uvicorn 0.30.6
Werkzeug 3.0.3
Django:
Same process follow in what i followed in fastapi
C:\Users\rakes\PycharmProjects\djangoProject>pip list
Package Version
----------------- -------
annotated-types 0.7.0
anyio 4.4.0
blinker 1.8.2
click 8.1.7
colorama 0.4.6
fastapi 0.112.1
Flask 3.0.3
Flask-SQLAlchemy 3.1.1
greenlet 3.0.3
h11 0.14.0
idna 3.7
itsdangerous 2.2.0
Jinja2 3.1.4
MarkupSafe 2.1.5
pip 23.2.1
psycopg2 2.9.9
psycopg2-binary 2.9.9
pydantic 2.8.2
pydantic_core 2.20.1
sniffio 1.3.1
SQLAlchemy 2.0.32
starlette 0.38.2
typing_extensions 4.12.2
uvicorn 0.30.6
Werkzeug 3.0.3
How to Activate Virtual Environment in different framework
Fast Api
.venv\Scripts\activate
C:\Users\rakes\PycharmProjects\flaskProject>.venv\Scripts\activate
(.venv) C:\Users\rakes\PycharmProjects\flaskProject>pip install flask_sqlalchemy
Flask
Same process follow in what i followed in fastapi
Django
Same process follow in what i followed in fastapi
ERROR: If psycho module not installed
step1:uninstall package
pip uninstall psycopg
pip uninstall psycopg2
pip uninstall psycopg2-binary
step2:install package
pip install psycopg
Top comments (0)