Managing FastAPI Projects with Poetry: A Step-by-Step Guide

Image
This guide will walk you through how to use Poetry to manage dependencies and structure your project in FastAPI . It includes detailed explanations of Poetry's core concepts and commands to help prevent issues that can arise during team collaboration and deployment. 1. What is Poetry? Poetry is a dependency management and packaging tool for Python. It goes beyond simply installing libraries by allowing you to clearly declare the dependencies your project needs and ensuring that all developers on the project have the same library versions. Clarity in Dependency Management : Explicitly manage your project's basic information and required libraries through the pyproject.toml file. Reproducible Builds : By locking all dependency versions in the poetry.lock file, it fundamentally prevents "it works on my machine" problems. Integrated Development Environment : It automatically creates and manages isolated virtual environments for each project and handles mo...

Opening a Port on Ubuntu Using UFW (Uncomplicated Firewall)

To open a specific port (in this case, 9040) on Ubuntu, we can use ufw (Uncomplicated Firewall), which is a user-friendly firewall tool in Ubuntu and other Linux.

For example, follow these steps to open port 9040 TCP :


1. Check UFW Status

First, check if UFW is enabled by running the following command in the terminal:


 jason@GU502DU:~$ sudo ufw status
 [sudo] password for jason:
 Status: active
 
 To                         Action      From
 --                         ------      ----
 22/tcp                     ALLOW       Anywhere
 9200/tcp                   ALLOW       Anywhere
 3000/tcp                   ALLOW       Anywhere
 22/tcp (v6)                ALLOW       Anywhere (v6)
 9200/tcp (v6)              ALLOW       Anywhere (v6)
 3000/tcp (v6)              ALLOW       Anywhere (v6)
 

If UFW is not active, you can enable it with:


 jason@GU502DU:~$ sudo ufw enable

 Command may disrupt existing ssh connections. Proceed with operation (y|n)? y

 Firewall is active and enabled on system startup


2. Open Port 9040

To open port 9040, use the following command:


 jason@GU502DU:~$ sudo ufw allow 9040/tcp

 Rule added
 Rule added (v6)

This command allows inbound connections on port 9040 using the TCP protocol.


3. Verify the Rules

To confirm the changes, check the current firewall rules with ufw status:


 jason@GU502DU:~$ sudo ufw status
 Status: active
 
 To                         Action      From
 --                         ------      ----
 9040/tcp                   ALLOW       Anywhere
 9040/tcp (v6)              ALLOW       Anywhere (v6)

In the output of this command, you should see that port 9040 is open.


Important Notes

  • Using Cloud Services : If you are using cloud services like AWS, Azure, or Google Cloud, you may also need to open the port in the network security groups or firewall settings provided by the cloud service provider.

Comments

Popular posts from this blog

Resolving Key Exchange Failure When Connecting with SecureCRT to OpenSSH

SecureCRT] How to Back Up and Restore SecureCRT Settings on Windows

How to Set Up Vaultwarden (Bitwarden) on Synology NAS (Best Free Alternative to LastPass)