Mr-Help commited on
Commit
6eacba4
·
verified ·
1 Parent(s): f29597e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ import requests
4
+
5
+ app = FastAPI()
6
+
7
+ # ClickUp API URL for creating a task (replace with your list ID)
8
+ LIST_ID = "901208781277"
9
+ URL = f"https://api.clickup.com/api/v2/list/{LIST_ID}/task"
10
+
11
+ # Your access token
12
+ ACCESS_TOKEN = "2144425825_36f2249dc27c5aca075ac5442b1bbcdf01c3a29b9e41b86bda46a6cf651acd0f"
13
+
14
+ # Headers for authorization
15
+ headers = {
16
+ "Authorization": ACCESS_TOKEN,
17
+ "Content-Type": "application/json"
18
+ }
19
+
20
+ class TaskData(BaseModel):
21
+ task_name: str
22
+ task_type: str # "Reel" or "Design"
23
+ campaign_name: str
24
+ platforms: list[str]
25
+ assignees: list[int] # List of user IDs
26
+ due_date: int # Unix timestamp in milliseconds
27
+
28
+ @app.post("/singetask")
29
+ def create_task(task: TaskData):
30
+ description = f"Task Type: {task.task_type}\nCampaign: {task.campaign_name}\nPlatforms: {', '.join(task.platforms)}"
31
+
32
+ payload = {
33
+ "name": task.task_name,
34
+ "description": description,
35
+ "assignees": task.assignees,
36
+ "priority": 3, # Priority levels: 1 (Low), 2 (Normal), 3 (High), 4 (Urgent)
37
+ "due_date": task.due_date, # Unix timestamp in milliseconds
38
+ "status": "to do" # Adjust based on your workflow
39
+ }
40
+
41
+ response = requests.post(URL, headers=headers, json=payload)
42
+ return {"status_code": response.status_code, "response": response.json()}