<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aaditya Sinha</title>
    <description>The latest articles on DEV Community by Aaditya Sinha (@aadityasinha_dotcom).</description>
    <link>https://dev.to/aadityasinha_dotcom</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F740417%2F7ec5e84b-1415-404a-8073-0e2c677738c9.jpeg</url>
      <title>DEV Community: Aaditya Sinha</title>
      <link>https://dev.to/aadityasinha_dotcom</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aadityasinha_dotcom"/>
    <language>en</language>
    <item>
      <title>Deploy your Flask API on GCP Cloud Run 🚀</title>
      <dc:creator>Aaditya Sinha</dc:creator>
      <pubDate>Sun, 12 Jan 2025 13:13:48 +0000</pubDate>
      <link>https://dev.to/aadityasinha_dotcom/deploy-your-flask-api-on-gcp-cloud-run-4ph0</link>
      <guid>https://dev.to/aadityasinha_dotcom/deploy-your-flask-api-on-gcp-cloud-run-4ph0</guid>
      <description>&lt;p&gt;Hey, there!! Do you wanna deploy your flask Api on GCP(Google Cloud Platform)? Here are simple and easy steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Set Up Your Flask Application
&lt;/h2&gt;

&lt;p&gt;Ensure your Flask application has the following structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/flask-app
  ├── app.py                  # Your main Flask application
  ├── requirements.txt        # Python dependencies
  ├── Dockerfile              # Docker configuration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example app.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/')
def home():
    return "Hello, World!"

@app.route('/api', methods=['POST'])
def api():
    data = request.get_json()
    return jsonify({"message": "Data received", "data": data}), 200

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example DockerFile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Step 1: Use Python base image
FROM python:3.10-slim

# Step 2: Set working directory
WORKDIR /app

# Step 3: Copy application files
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# Step 4: Expose the port and specify the startup command
EXPOSE 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "app:app"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Create an Artifact Registry Repository
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Enable Artifact Registry in your Google Cloud project:&lt;br&gt;
&lt;code&gt;gcloud services enable artifactregistry.googleapis.com&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a Docker repository in Artifact Registry:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud artifacts repositories create flask-repo \
    --repository-format=docker \
    --location=us-central1 \
    --description="Repository for Flask application"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Authenticate Docker with Artifact Registry:
&lt;code&gt;gcloud auth configure-docker us-central1-docker.pkg.dev&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 3: Build and Push the Docker Image
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Build the Docker image:&lt;br&gt;
&lt;code&gt;docker build -t us-central1-docker.pkg.dev/&amp;lt;PROJECT_ID&amp;gt;/flask-repo/flask-app:v1 .&lt;/code&gt;&lt;br&gt;
Replace  with your Google Cloud project ID.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Push the Docker image to Artifact Registry:&lt;br&gt;
&lt;code&gt;docker push us-central1-docker.pkg.dev/&amp;lt;PROJECT_ID&amp;gt;/flask-repo/flask-app:v1&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 4: Deploy to Cloud Run
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Deploy the image to Cloud Run:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud run deploy flask-app \
    --image us-central1-docker.pkg.dev/&amp;lt;PROJECT_ID&amp;gt;/flask-repo/flask-app:v1 \
    --platform managed \
    --region us-central1 \
    --allow-unauthenticated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Note the URL provided after deployment. Your Flask app will now be accessible via this URL.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 5: Verify the Deployment
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Access the Application: Visit the Cloud Run service URL in your browser or use curl:&lt;br&gt;
&lt;code&gt;curl https://&amp;lt;CLOUD_RUN_SERVICE_URL&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check Logs: If anything goes wrong, inspect the logs:&lt;br&gt;
&lt;code&gt;gcloud logs read --platform run --region us-central1 --service flask-app&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 6: Clean Up (Optional)
&lt;/h2&gt;

&lt;p&gt;If you no longer need the service, delete it to avoid unnecessary charges:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcloud run services delete flask-app --region us-central1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;These steps ensure a smooth workflow for deploying Flask applications to Google Cloud Run with Artifact Registry. Thank You!!&lt;/p&gt;

</description>
      <category>gcp</category>
      <category>googlecloud</category>
      <category>flask</category>
      <category>python</category>
    </item>
    <item>
      <title>Latex with Vim</title>
      <dc:creator>Aaditya Sinha</dc:creator>
      <pubDate>Sun, 29 Sep 2024 05:34:25 +0000</pubDate>
      <link>https://dev.to/aadityasinha_dotcom/latex-with-vim-1f84</link>
      <guid>https://dev.to/aadityasinha_dotcom/latex-with-vim-1f84</guid>
      <description>&lt;h2&gt;
  
  
  Latex
&lt;/h2&gt;

&lt;p&gt;A LaTeX document is a text file that contains the markup code for a document that will be typeset by LaTeX. The markup code specifies the structure and formatting of the document, such as the headings, paragraphs, lists, figures, and tables. LaTeX documents typically have the file extension .tex.&lt;br&gt;
LaTeX documents can be used to create a wide variety of documents, including technical papers, books, presentations, and even letters. They are especially well-suited for documents that contain complex mathematical equations or other specialized formatting.&lt;/p&gt;
&lt;h2&gt;
  
  
  Vimtex
&lt;/h2&gt;

&lt;p&gt;So as you have already know about vim and latex, there is a plugin which is called vimtex that can be used to compile the .tex file and shows you the output just like the screenshot above. But before diving into the features of this plugin you must add this plugin into you lvim or nvim config file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yacvqdnq7m2ros5p72v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yacvqdnq7m2ros5p72v.png" alt="Writing latex using vim"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;" vim-plug
Plug 'lervag/vimtex'

" packer.nvim
use 'lervag/vimtex'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installing vimtex you must add the latex_compiler to compile the .tex file using this line into you .vimrc or init.vim&lt;br&gt;
let g:vimtex_compiler_method = 'latexrun'&lt;br&gt;
There are so many commands for vimtex, the commands which I use everytime is \ll (to compile the latex file).&lt;br&gt;
For pdf viewer I have used zathura which is minimalistic pdf viewer with vim key bind.&lt;/p&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope this article helped you getting to know about latex file and vimtex plugin, how we can use it in vim :)&lt;br&gt;
See you in the next article.&lt;br&gt;
&lt;a href="https://github.com/lervag/vimtex.git" rel="noopener noreferrer"&gt;https://github.com/lervag/vimtex.git&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>linux</category>
      <category>bash</category>
      <category>vim</category>
    </item>
  </channel>
</rss>
