Skip to content

GuptajiRocks/Flask-Weather-App

 
 

Repository files navigation

Flask App with RapidAPI Integration

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.

Table of Contents

  1. Introduction
  2. Prerequisites
  3. Installation
  4. Configuration
  5. Running the App
  6. Project Structure
  7. Usage
  8. Contributing
  9. License

Introduction

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.

Prerequisites

Before you start, make sure you have the following installed:

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/flask-rapidapi-starter.git
    cd flask-rapidapi-starter
  2. Create a virtual environment:

    python -m venv venv
  3. Activate the virtual environment:

    • Windows:

      venv\Scripts\activate
    • macOS/Linux:

      source venv/bin/activate
  4. Install the required dependencies:

    pip install -r requirements.txt

Configuration

  1. Create a .env file in the root directory of the project and add your RapidAPI key:

    RAPIDAPI_KEY=your_rapidapi_key
    
  2. Configure the API URL and other parameters in config.py:

    RAPIDAPI_HOST = "your_rapidapi_host"
    API_URL = "https://example-rapidapi.p.rapidapi.com/api"

Running the App

  1. Run the Flask development server:

    flask run
  2. Open your browser and go to http://127.0.0.1:5000/.

Project Structure

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)

Usage

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

Contributing

Contributions are welcome! Please fork this repository and submit a pull request for any improvements or bug fixes.

Packages

No packages published

Languages

  • HTML 50.1%
  • Python 46.1%
  • CSS 3.7%
  • JavaScript 0.1%