This is a starter project for building a Flask application that integrates with an external API using RapidAPI. This project serves as a basic template for beginners looking to understand how to use APIs with Flask.
- Introduction
- Prerequisites
- Installation
- Configuration
- Running the App
- Project Structure
- Usage
- Contributing
- License
This project demonstrates how to create a simple Flask web application that makes API requests to an external service via RapidAPI. It covers the basics of setting up a Flask server, configuring the environment, and integrating with an external API.
Before you start, make sure you have the following installed:
- Python 3.x
- Flask
- A RapidAPI account (sign up for free here)
-
Clone the repository:
git clone https://github.com/your-username/flask-rapidapi-starter.git cd flask-rapidapi-starter
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
-
Windows:
venv\Scripts\activate
-
macOS/Linux:
source venv/bin/activate
-
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory of the project and add your RapidAPI key:RAPIDAPI_KEY=your_rapidapi_key
-
Configure the API URL and other parameters in
config.py
:RAPIDAPI_HOST = "your_rapidapi_host" API_URL = "https://example-rapidapi.p.rapidapi.com/api"
-
Run the Flask development server:
flask run
-
Open your browser and go to
http://127.0.0.1:5000/
.
flask-rapidapi-starter/
│
├── app.py # Main Flask app file
├── config.py # Configuration file for API settings
├── requirements.txt # Python dependencies
├── .env # Environment variables (ignored in version control)
├── templates/ # HTML templates for the app
└── static/ # Static files (CSS, JS, images)
-
Home Page:
- Displays a form to input data that will be sent to the external API.
-
API Integration:
- Sends the user input to the configured RapidAPI endpoint and displays the response.
Contributions are welcome! Please fork this repository and submit a pull request for any improvements or bug fixes.