Spaces:
Sleeping
Sleeping
File size: 1,054 Bytes
afcb001 7f88e89 afcb001 43e3c07 afcb001 43e3c07 afcb001 e7beaed afcb001 43e3c07 afcb001 43e3c07 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
from pydantic import BaseModel
from fastapi.middleware.cors import CORSMiddleware
from fastapi import FastAPI, HTTPException
from linkedin_api import Linkedin
app = FastAPI()
# Enable CORS
# app.add_middleware(
# CORSMiddleware,
# allow_origins=["*"],
# allow_credentials=True,
# allow_methods=["*"],
# allow_headers=["*"],
# )
# Authenticate using any Linkedin account credentials
class GenerateInput(BaseModel):
prompt: str
def fetch_profile(prompt: str):
if not prompt.strip():
raise HTTPException(status_code=400, detail="Please provide a non-empty prompt.")
api = Linkedin('[email protected]', '#845524509suma')
c = api.get_profile(prompt)
return c
@app.head("/")
async def head_root():
return {"message": "This is a HEAD request to the root URL."}
@app.get("/", tags=["Home"])
def api_home():
return {'detail': 'Welcome to FastAPI LinkedIn Crawler by Knowde!'}
@app.post("/api/fetch", tags=["Fetch"])
def inference(data: GenerateInput):
return fetch_profile(data.prompt) |