CAHNGE *-DOMAIN to *-BASEURL to handle protocols better #5
This commit is contained in:
parent
03b21d932e
commit
028a41d86a
3 changed files with 42 additions and 24 deletions
28
main.py
28
main.py
|
|
@ -7,25 +7,25 @@ import os
|
|||
app = FastAPI(title="Aukpad Proxy Service", description="Proxy service for aukpad.com to linedump.com")
|
||||
|
||||
# Configuration from environment variables
|
||||
PAD_DOMAIN = os.getenv("PAD_DOMAIN", "aukpad.com")
|
||||
DUMP_DOMAIN = os.getenv("DUMP_DOMAIN", "linedump.com")
|
||||
PROXY_DOMAIN = os.getenv("PROXY_DOMAIN", "bin.aukpad.com")
|
||||
PAD_BASEURL = os.getenv("PAD_BASEURL", "https://aukpad.com")
|
||||
DUMP_BASEURL = os.getenv("DUMP_BASEURL", "https://linedump.com")
|
||||
PROXY_BASEURL = os.getenv("PROXY_BASEURL", "https://bin.aukpad.com")
|
||||
|
||||
@app.get("/{paste_id}")
|
||||
async def proxy_paste(paste_id: str):
|
||||
try:
|
||||
# Fetch content from pad domain
|
||||
pad_url = f"https://{PAD_DOMAIN}/{paste_id}/raw"
|
||||
|
||||
pad_url = f"{PAD_BASEURL}/{paste_id}/raw"
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
# Get content from pad
|
||||
pad_response = await client.get(pad_url)
|
||||
pad_response.raise_for_status()
|
||||
content = pad_response.text
|
||||
|
||||
|
||||
# Post content to dump domain
|
||||
dump_response = await client.post(
|
||||
f"https://{DUMP_DOMAIN}",
|
||||
DUMP_BASEURL,
|
||||
data=content,
|
||||
headers={"Content-Type": "text/plain"}
|
||||
)
|
||||
|
|
@ -48,13 +48,13 @@ async def proxy_paste(paste_id: str):
|
|||
async def root():
|
||||
return {
|
||||
"service": "Aukpad Proxy Service",
|
||||
"description": f"This service proxies paste content from {PAD_DOMAIN} to {DUMP_DOMAIN}",
|
||||
"usage": f"Visit https://{PROXY_DOMAIN}/{{paste_id}} to fetch content from https://{PAD_DOMAIN}/{{paste_id}}/raw and redirect to the posted URL on {DUMP_DOMAIN}",
|
||||
"example": f"https://{PROXY_DOMAIN}/abc123 → fetches https://{PAD_DOMAIN}/abc123/raw → posts to https://{DUMP_DOMAIN} → redirects to result URL",
|
||||
"domains": {
|
||||
"proxy": PROXY_DOMAIN,
|
||||
"source": PAD_DOMAIN,
|
||||
"destination": DUMP_DOMAIN
|
||||
"description": f"This service proxies paste content from {PAD_BASEURL} to {DUMP_BASEURL}",
|
||||
"usage": f"Visit {PROXY_BASEURL}/{{paste_id}} to fetch content from {PAD_BASEURL}/{{paste_id}}/raw and redirect to the posted URL on {DUMP_BASEURL}",
|
||||
"example": f"{PROXY_BASEURL}/abc123 → fetches {PAD_BASEURL}/abc123/raw → posts to {DUMP_BASEURL} → redirects to result URL",
|
||||
"base_urls": {
|
||||
"proxy": PROXY_BASEURL,
|
||||
"source": PAD_BASEURL,
|
||||
"destination": DUMP_BASEURL
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue