This is an asynchronous task manager built with FastAPI and deployed on Heroku. It allows users to create and track long-running tasks that are processed asynchronously in the background using BackgroundTasks and asyncio.
- Asynchronous task management using
asyncioand FastAPI'sBackgroundTasks. - Deploys on Heroku using
uvicornas the ASGI server. - Real-time API documentation and interactive testing through FastAPI's Swagger UI.
- FastAPI: Web framework for building APIs.
- Uvicorn: ASGI server to run FastAPI.
- Python: Programming language for writing the application.
- Heroku: Cloud platform for deployment.
Ensure that you have the following installed on your local development machine:
- Python 3.x
- FastAPI
- Uvicorn
- Git
- Heroku CLI (for deployment)
-
Clone the Repository
First, clone the repository to your local machine using Git:
git clone https://github.com/yourusername/async-task-manager.git cd async-task-manager -
Create and Activate Virtual Environment
Create a Python virtual environment and activate it:
python -m venv venv source venv/bin/activate # For Mac/Linux venv\Scripts\activate # For Windows
-
Install Dependencies
Install all the dependencies listed in the
requirements.txtfile:pip install -r requirements.txt
-
Run the Development Server
Start the Uvicorn development server locally:
uvicorn app:app --reload
Open your browser and visit:
http://localhost:8000You should see a JSON message returned by the FastAPI application.
-
Access Swagger Documentation
To explore and test the API using FastAPI's Swagger documentation, open your browser and visit:
http://localhost:8000/docs
-
Login to Heroku
Make sure you have Heroku CLI installed. Then, login to Heroku:
heroku login
-
Create a Heroku App
Create a new Heroku app using the following command:
heroku create your-app-name
-
Deploy the App
Push the code to Heroku and deploy the FastAPI app:
git push heroku main
-
Visit the Live App
Once the deployment is successful, you can open the live application using:
heroku open
Your app should now be live on the web!
The live application is available at:

https://async-task-4e020a9578b4.herokuapp.com/docs
async-task-manager/
├── app.py
├── task_manager/
│ ├── __init__.py
│ └── background_tasks.py
├── venv/
├── requirements.txt
├── Procfile
├── README.md
└── runtime.txt (optional)
Once the app is deployed, you can access it at the following URL:
https://async-task-4e020a9578b4.herokuapp.com/
FastAPI provides an interactive API documentation (Swagger UI) that allows you to test and call the API.
-
To access the documentation, visit the following URL:
https://async-task-4e020a9578b4.herokuapp.com/docs -
This will open an interactive interface where you can view and test all available API endpoints.
The application provides multiple API endpoints for interacting with the system. Below are examples:
This endpoint creates and runs a long-running task in the background. You can submit data to trigger the task.
- URL:
/run-task/ - Method:
POST - Parameters: Submit
JSONdata in the request body- Example data:
{ "task_data": "example_task_data" }
- Example data:
- Response: Upon success, you will receive a message indicating the task is running in the background:
{ "message": "Task is running in the background" }
This endpoint is used to check the status of a running task if task status tracking is implemented.
- URL:
/status/{task_id} - Method:
GET - Parameters:
task_id: The unique ID of the task created previously
- Response: You will receive the current status of the task, for example:
{ "task_id": "12345", "status": "in_progress" }
You can use tools like curl or Postman to test the API.
-
Using
curlto test the API:curl -X POST https://async-task-4e020a9578b4.herokuapp.com/run-task/ -H "Content-Type: application/json" -d '{"task_data": "example_task_data"}'
-
Using Postman to test the API:
- Open Postman and create a new request.
- Set the request method to
POSTand enter the API URLhttps://async-task-4e020a9578b4.herokuapp.com/run-task/. - In the Body section, select
rawand chooseJSONformat, then enter the data:{ "task_data": "example_task_data" } - Send the request and check the response.
- Task status tracking (e.g.,
pending,in_progress,completed). - Integration with databases for task persistence.
- WebSocket integration for real-time task progress updates.
This project is open-source and available under the MIT License.