Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/faraasat/fastapi-vercel-example
Example code for article - Simple Guide on Deploying Python FastAPI on Vercel — Free of Cost
https://github.com/faraasat/fastapi-vercel-example
application-programming-interface deployment fastapi python python3 vercel vercel-deployment
Last synced: about 2 months ago
JSON representation
Example code for article - Simple Guide on Deploying Python FastAPI on Vercel — Free of Cost
- Host: GitHub
- URL: https://github.com/faraasat/fastapi-vercel-example
- Owner: faraasat
- Created: 2023-12-05T02:18:43.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-03-07T05:50:39.000Z (10 months ago)
- Last Synced: 2024-07-30T18:04:22.353Z (5 months ago)
- Topics: application-programming-interface, deployment, fastapi, python, python3, vercel, vercel-deployment
- Language: Python
- Homepage: https://fastapi-vercel-example-phi.vercel.app/
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI Vercel Example
### This Example Code is a Part of an Article: Simple Guide on Deploying Python FastAPI on Vercel — Free of Cost
##### Live Url: [Deployment](https://fastapi-vercel-example-phi.vercel.app/)
##### Article Link: [Medium](https://faraasat.medium.com/simple-guide-on-deploying-python-fastapi-on-vercel-free-of-cost-549e879305d6)
### Introduction:
Whether you’re working on a hobby project or a professional endeavor, deployment is essential. FastAPI, a high-performance web framework for building APIs with Python, offers an efficient way to handle concurrent tasks using asynchronous programming. In this guide, we’ll explore deploying a FastAPI application on Vercel, which provides a straightforward interface for continuous deployment, and the best part—it’s free!### Steps for Deployment:
#### 1. Initialize the Project:
- Create a new project directory (e.g., flask-api-example).
- Set up a virtual environment (optional but recommended).
- Install Python dependencies specified in the requirements.txt file.
#### 2. Write the API:
- Create an index.py file within a directory (e.g., api).
- Define your FastAPI routes and endpoints (e.g., a simple “Hello World” response).
#### 3. Configure .gitignore:
- Initialize a Git repository.
- Add a .gitignore file to exclude specific files and directories (e.g., IDE-related files, cache, and virtual environments).
#### 4. Create vercel.json:
- Add a vercel.json file at the root of your app.
- Specify the build process and routes for Vercel deployment.
#### 5. Deploy on Vercel:
- Using Vercel CLI:
- Install Vercel CLI globally (npm i -g vercel).
- Log in to the CLI using vercel login.
- Deploy using vercel commands.
- Using GitHub/GitLab Integration:
- Connect your Vercel account to your Git repository.
- Automatically deploy on every push to the repository.### Conclusion:
By following these steps, you can deploy your Python FastAPI application on Vercel without any cost. Enjoy hassle-free deployment and focus on building great APIs! 🚀.### Result:
![screencapture-fastapi-vercel-example-phi-vercel-app-2024-03-07-10_45_29](https://github.com/faraasat/fastapi-vercel-example/assets/63093876/be15d870-211a-4cc1-b0b3-033d05e62cb6)