pylint 10.0
This commit is contained in:
parent
6c2db118da
commit
3e7de5dadf
@ -1,8 +1,9 @@
|
|||||||
from fastapi import FastAPI
|
"""Unshorten API"""
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from unshorten import unshorten_twitter
|
from fastapi import FastAPI
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
from unshorteners import unshorten_twitter
|
||||||
|
|
||||||
UNSHORTENERS = {
|
UNSHORTENERS = {
|
||||||
't.co': unshorten_twitter
|
't.co': unshorten_twitter
|
||||||
@ -20,12 +21,12 @@ app.add_middleware(
|
|||||||
|
|
||||||
@app.get('/')
|
@app.get('/')
|
||||||
async def receive_url(url: Optional[str] = None):
|
async def receive_url(url: Optional[str] = None):
|
||||||
|
"""Receives a URL to unshorten"""
|
||||||
if url is None:
|
if url is None:
|
||||||
return {"error": "no url provided"}
|
return {"error": "no url provided"}
|
||||||
|
|
||||||
domain = urlparse(url).netloc
|
domain = urlparse(url).netloc
|
||||||
|
|
||||||
if domain not in UNSHORTENERS:
|
if domain not in UNSHORTENERS:
|
||||||
return {"error": f"cannot unshorten {domain}"}
|
return {"error": f"cannot unshorten {domain}"}
|
||||||
else:
|
|
||||||
return UNSHORTENERS[domain](url)
|
return UNSHORTENERS[domain](url)
|
||||||
|
Loading…
Reference in New Issue
Block a user