Skip to content

be-at/http-proxy-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

HTTP Proxy API

This repository contains two implementations of a generic HTTP proxy API: one using FastAPI and the other using Flask. Both APIs forward incoming requests to a target API specified via query parameters.


Files

  • fast_api.py: Implementation using FastAPI with async support.
  • flask_api.py: Implementation using Flask (synchronous).

Features

  • Supports all common HTTP methods: GET, POST, PUT, DELETE, PATCH.
  • Forwards headers and body to the target API.
  • Filters query parameters to exclude api when forwarding.
  • Excludes certain headers that may break the response (content-encoding, transfer-encoding, connection).

Installation

  1. Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate  # Linux/macOS
venv\Scripts\activate     # Windows
  1. Install dependencies:
pip install fastapi[all] flask requests httpx uvicorn

Usage

FastAPI Version

Run the FastAPI proxy:

uvicorn fast_api:app --reload --port 8000

Flask Version

Run the Flask proxy:

python flask_api.py

Example request using curl:

curl "http://127.0.0.1:8000/users/1?api=https://jsonplaceholder.typicode.com"
  • This will forward the request to https://jsonplaceholder.typicode.com/users/1.

or

curl "http://127.0.0.1:8000/users/?api=https://api.telegram.org"

Notes

  • Both implementations forward headers and body.
  • Use api query parameter to specify the target API base URL.
  • Any additional query parameters will also be forwarded.

Example with POST

curl -X POST "http://127.0.0.1:8000/posts?api=https://jsonplaceholder.typicode.com" \
     -H "Content-Type: application/json" \
     -d '{"title": "foo", "body": "bar", "userId": 1}'
  • This forwards the POST request to the target API with JSON body.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages