mattoofahaddcube commited on
Commit
16c5840
β€’
1 Parent(s): 55ec865

adding hf token read

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +2 -1
  3. config.py +1 -0
README.md CHANGED
@@ -29,7 +29,7 @@ pinned: false
29
  3. Run the local server:
30
 
31
  ```bash
32
- uvicorn main:app --host 0.0.0.0 --port 5000
33
  ```
34
 
35
  ## Docker
 
29
  3. Run the local server:
30
 
31
  ```bash
32
+ uvicorn app:app --host 0.0.0.0 --port 5000
33
  ```
34
 
35
  ## Docker
app.py CHANGED
@@ -3,6 +3,7 @@ from fastapi import FastAPI, Request
3
  from fastapi.responses import PlainTextResponse
4
  from pydantic import BaseModel
5
  import json
 
6
 
7
  from logs import logger, log_execution_time
8
 
@@ -16,9 +17,9 @@ async def twilio_message_endpoint(request: Request):
16
  user_input = data.get("Body", "")
17
  reqUrl = "https://mattoofahad-whatsapp-endpoint.hf.space/message"
18
  headersList = {
19
- "User-Agent": "Thunder Client (https://www.thunderclient.com)",
20
  "accept": "application/json",
21
  "Content-Type": "application/json",
 
22
  }
23
  payload = json.dumps({"user_input": str(user_input)})
24
  response = requests.request("POST", reqUrl, data=payload, headers=headersList)
 
3
  from fastapi.responses import PlainTextResponse
4
  from pydantic import BaseModel
5
  import json
6
+ from config import READ_HF_TOKEN
7
 
8
  from logs import logger, log_execution_time
9
 
 
17
  user_input = data.get("Body", "")
18
  reqUrl = "https://mattoofahad-whatsapp-endpoint.hf.space/message"
19
  headersList = {
 
20
  "accept": "application/json",
21
  "Content-Type": "application/json",
22
+ "Authorization": f"Bearer {READ_HF_TOKEN}"
23
  }
24
  payload = json.dumps({"user_input": str(user_input)})
25
  response = requests.request("POST", reqUrl, data=payload, headers=headersList)
config.py CHANGED
@@ -5,3 +5,4 @@ from dotenv import find_dotenv, load_dotenv
5
  load_dotenv(find_dotenv(), override=True)
6
 
7
  LOGGER_LEVEL = os.getenv("LOGGER_LEVEL")
 
 
5
  load_dotenv(find_dotenv(), override=True)
6
 
7
  LOGGER_LEVEL = os.getenv("LOGGER_LEVEL")
8
+ READ_HF_TOKEN = os.getenv("READ_HF_TOKEN")