Update app.py
Browse files123464 unmodified lines697071727374757677from fastapi import FastAPI, HTTPException, Depends, Securityfrom fastapi.security import HTTPBearerfrom pydantic import BaseModelfrom transformers import GPT2LMHeadModel, GPT2TokenizerFast, GPT2Config64 unmodified lines@app.post("/analyze")async def analyze_text(data: TextInput, token: str = Depends(bearer_scheme)):user_input = data.text.strip()if not user_input:raise HTTPException(status_code=400, detail="Text cannot be empty")# The token is automatically extracted from the Authorization header# You can validate the token here if neededprint(f"Received Bearer Token: {token}")123464 unmodified lines697071727374757677787980818283from fastapi import FastAPI, HTTPException, Dependsfrom fastapi.security import HTTPBearerfrom pydantic import BaseModelfrom transformers import GPT2LMHeadModel, GPT2TokenizerFast, GPT2Config64 unmodified lines@app.post("/analyze")async def analyze_text(data: TextInput, token: str = Depends(bearer_scheme)):user_input = data.text.strip()if not user_input:raise HTTPException(status_code=400, detail="Text cannot be empty")# Check if there are at least two wordsword_count = len(user_input.split())if word_count < 2:raise HTTPException(status_code=400, detail="Text must contain at least two words")# The token is automatically extracted from the Authorization header# You can validate the token here if neededprint(f"Received Bearer Token: {token}")
app.py+8-2