mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 04:51:51 +09:00
23 lines
No EOL
600 B
Python
23 lines
No EOL
600 B
Python
from fastapi import FastAPI, Query, HTTPException
|
|
from fastapi.responses import Response
|
|
import lib.target as target
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.post("/start")
|
|
async def start(url: str = Query(None)):
|
|
if url:
|
|
target.save(url)
|
|
print(f"Target URL set to: {url}")
|
|
return {"message": f"Target URL set to: {url}"}
|
|
return {"error": "No URL provided"}
|
|
|
|
|
|
@app.exception_handler(404)
|
|
async def not_found_handler(request, exc):
|
|
return Response(status_code=404)
|
|
|
|
@app.exception_handler(405)
|
|
async def method_not_allowed_handler(request, exc):
|
|
return Response(status_code=405) |