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...

How to Add Syntax Highlighting to Blogger Using Prism.js

There are many great platforms these days for starting a technical blog, but most are either paid or require a bit of setup.

That’s why I chose Blogger — it's free, simple, and easy to get started.

However, as a technical blogger, I often need to share things like Linux commands, source code snippets, or terminal outputs — and unfortunately, Blogger doesn't support code blocks natively.

To resolve this, I added a syntax highlighting library called Prism.js to my Blogger theme so that code in my posts looks clean and readable.

How to Set Up Prism.js for Syntax Highlighting in Blogger

Step 1: Open the Blogger Theme Editor

  1. Log in to your Blogger account
  2. On the left menu, click “Theme”
  3. Click the "▼ arrow" next to the current theme and select "Edit HTML"


Step 2: Add Prism.js to the <head> section

  1. In the HTML editor, find the <head> tag near the top of the code.
  2. Add the following lines inside the <head> tag:
  3. Click the Save button (top right corner)
<head>
  <meta content='width=device-width, initial-scale=1' name='viewport'/>
  <title><data:view.title.escaped/></title>

  <!-- Prism CSS -->
  <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css" rel="stylesheet" />

  <!-- Prism JS (Core) -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>

  <!-- Language Components -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-java.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-bash.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-http.min.js"></script>
⚠️ Important: Do not self-close <script> tags like
<script ... />.
Always use the full format: <script>...</script>

How to Use Code Blocks in Your Posts

When writing a post, switch to “HTML view” and insert code using the <pre><code> format like this:

<pre><code class="language-bash">
sudo netplan apply
</code></pre>
<pre><code class="language-java">
System.out.println("Hello, world!");
</code></pre>
<pre><code class="language-python">
def hello():
    print("Hello, world!")
</code></pre>
<pre><code class="language-http">
GET /api/users HTTP/1.1
Host: example.com
</code></pre>

Switch to a Dark Theme for Prism.js

If you prefer a dark look for your code blocks, simply swap the CSS link with a different Prism theme:

<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-okaidia.min.css" rel="stylesheet" />

Other popular themes include:

  • prism-tomorrow
  • prism-coy
  • prism-dark

See all themes: https://prismjs.com

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)