Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,24 +1,15 @@
|
|
1 |
-
from fastapi import FastAPI,
|
2 |
-
from fastapi.responses import
|
3 |
-
from fastapi.responses import StreamingResponse
|
4 |
-
from fastapi.responses import FileResponse
|
5 |
from fastapi.middleware.cors import CORSMiddleware
|
6 |
-
from
|
7 |
-
import os
|
8 |
-
import uuid,requests
|
9 |
|
10 |
GOOD_BOY_URL = (
|
11 |
"https://images.unsplash.com/photo-1518717758536-85ae29035b6d?ixlib=rb-1.2.1"
|
12 |
"&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80"
|
13 |
)
|
14 |
|
15 |
-
|
16 |
-
from fastapi import FastAPI, Request, HTTPException
|
17 |
-
from fastapi.responses import PlainTextResponse
|
18 |
-
from twilio.twiml.messaging_response import MessagingResponse
|
19 |
-
|
20 |
-
|
21 |
app = FastAPI()
|
|
|
22 |
app.add_middleware(
|
23 |
CORSMiddleware,
|
24 |
allow_origins=["*"],
|
@@ -27,8 +18,6 @@ app.add_middleware(
|
|
27 |
allow_headers=["*"],
|
28 |
)
|
29 |
|
30 |
-
|
31 |
-
|
32 |
@app.post("/whatsapp")
|
33 |
async def reply_whatsapp(request: Request):
|
34 |
form_data = await request.form()
|
@@ -38,8 +27,9 @@ async def reply_whatsapp(request: Request):
|
|
38 |
|
39 |
response = MessagingResponse()
|
40 |
|
41 |
-
msg = response.message(f"
|
42 |
msg.media(GOOD_BOY_URL)
|
43 |
|
44 |
-
return str(response)
|
45 |
|
|
|
|
1 |
+
from fastapi import FastAPI, Request, HTTPException
|
2 |
+
from fastapi.responses import PlainTextResponse
|
|
|
|
|
3 |
from fastapi.middleware.cors import CORSMiddleware
|
4 |
+
from twilio.twiml.messaging_response import MessagingResponse
|
|
|
|
|
5 |
|
6 |
GOOD_BOY_URL = (
|
7 |
"https://images.unsplash.com/photo-1518717758536-85ae29035b6d?ixlib=rb-1.2.1"
|
8 |
"&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80"
|
9 |
)
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
app = FastAPI()
|
12 |
+
|
13 |
app.add_middleware(
|
14 |
CORSMiddleware,
|
15 |
allow_origins=["*"],
|
|
|
18 |
allow_headers=["*"],
|
19 |
)
|
20 |
|
|
|
|
|
21 |
@app.post("/whatsapp")
|
22 |
async def reply_whatsapp(request: Request):
|
23 |
form_data = await request.form()
|
|
|
27 |
|
28 |
response = MessagingResponse()
|
29 |
|
30 |
+
msg = response.message(f"Hi, your number is {from_number} and you said {message_body}")
|
31 |
msg.media(GOOD_BOY_URL)
|
32 |
|
33 |
+
return PlainTextResponse(str(response))
|
34 |
|
35 |
+
# Run the application (Make sure you have the necessary setup to run FastAPI)
|