from fastapi import FastAPI, HTTPException from pydantic import BaseModel from typing import Dict app = FastAPI() database: Dict[str, str] = {} class DataItem(BaseModel): key: str value: str @app.post("/data") def store_data(item: DataItem): database[item.key] = item.value return {"message": "Data stored successfully"} @app.get("/data/{key}") def get_data(key: str): if key not in database: raise HTTPException(status_code=404, detail="Key not found") return {"key": key, "value": database[key]} import socketserver from http.server import SimpleHTTPRequestHandler class Proxy(SimpleHTTPRequestHandler): def do_GET(self): self.copyfile(self.send_head(), self.wfile) if __name__ == "__main__": import sys from http.server import HTTPServer port = int(sys.argv[1]) if len(sys.argv) > 1 else 8888 with HTTPServer(("", port), Proxy) as httpd: print(f"Serving HTTP proxy on port {port}") httpd.serve_forever()
top of page

There’s Nothing Here...

We can’t find the page you’re looking for.
Check the URL, or head back home.

Dar Es Salaam Tanzania

East Africa

Netwika © Copyright™

Jigo Send Company

559642545_1338642944303509_940588436868435484_n_edited.png
Accessibility.avif
Mars.png
bottom of page
import requests API_URL = "http://:8080/data" PROXY = {"http": "http://:8888", "https": "http://:8888"} def store_data(): resp = requests.post(API_URL, json={"key": "device1", "value": "hello"}, proxies=PROXY) print(resp.json()) def get_data(): resp = requests.get(API_URL + "/device1", proxies=PROXY) print(resp.json()) store_data() get_data()