SivaMallikarjun commited on
Commit
fa119c4
·
verified ·
1 Parent(s): 001c017

ProjectInsta/app.py

Browse files
Files changed (1) hide show
  1. ProjectInsta/app.py +0 -48
ProjectInsta/app.py DELETED
@@ -1,48 +0,0 @@
1
- from fastapi import FastAPI, Request
2
- from fastapi.responses import HTMLResponse
3
- from fastapi.staticfiles import StaticFiles
4
- from jinja2 import Environment, FileSystemLoader
5
- import json
6
-
7
- app = FastAPI()
8
-
9
- # Load templates
10
- env = Environment(loader=FileSystemLoader("templates"))
11
-
12
- # Serve static files
13
- app.mount("/static", StaticFiles(directory="static"), name="static")
14
-
15
- # In-memory work status (Replace with DB in production)
16
- work_status = {
17
- "id": 1,
18
- "task": "Project Milestone",
19
- "status": "In Progress",
20
- "children": [
21
- {"id": 2, "task": "Design UI", "status": "Completed", "children": []},
22
- {"id": 3, "task": "Develop API", "status": "In Progress", "children": []},
23
- ],
24
- }
25
-
26
- @app.get("/", response_class=HTMLResponse)
27
- async def home():
28
- template = env.get_template("index.html")
29
- return template.render()
30
-
31
- @app.get("/get_tree")
32
- async def get_tree():
33
- return work_status
34
-
35
- @app.post("/update_task")
36
- async def update_task(request: Request):
37
- data = await request.json()
38
- task_id = data["id"]
39
- new_status = data["status"]
40
-
41
- def update_status(node):
42
- if node["id"] == task_id:
43
- node["status"] = new_status
44
- for child in node.get("children", []):
45
- update_status(child)
46
-
47
- update_status(work_status)
48
- return {"message": "Task updated successfully!"}