Skip to content

Commit

Permalink
updated mangum and sarufi version
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalebu committed May 9, 2024
1 parent 398ee01 commit b68802d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 9 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Messenger application blueprint

on:
# Trigger the workflow on push
push:
branches:
# Push events on main branch
- main

# The Job defines a series of steps that execute on the same runner.
jobs:
CI:
# Define the runner used in the workflow
runs-on: ubuntu-latest
steps:
# Check out repo so our workflow can access it
- uses: actions/checkout@v2

# Step-1 Setup Python
- name: Set up Python
# This action sets up a Python environment for use in actions
uses: actions/setup-python@v4
with:
python-version: "3.11"
# optional: architecture: x64 x64 or x86. Defaults to x64 if not specified

# Step-2 Install Python Virtual ENV
- name: Install Python Virtual ENV
run: pip3 install virtualenv

# Step-3 Setup Virtual ENV
# https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows
- name: Virtual ENV
uses: actions/cache@v2
id: cache-venv # name for referring later
with:
path: venv # what we cache: the Virtual ENV
# The cache key depends on requirements.txt
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-venv-
# Step-4 Build a Virtual ENV, but only if it doesn't already exist
- name: Activate Virtual ENV
run: python -m venv venv && source venv/bin/activate && pip3 install -r requirements.txt
if: steps.cache-venv.outputs.cache-hit != 'true'

- name: Create archive of dependencies
run: |
ls ./venv/lib/python3.11/
rm -rf ./venv/lib/python3.11/site-packages/typing-*
rm -rf ./venv/lib/python3.11/site-packages/typing.py
cd ./venv/lib/python3.11/site-packages/
zip -r9 ../../../../api.zip .
- name: Add API files to Zip file
run: zip api.zip -r . -x "venv/*"
- name: Upload zip file artifact
uses: actions/upload-artifact@v2
with:
name: api
path: api.zip
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from sarufi import Sarufi
from dotenv import load_dotenv
from pymessenger.bot import Bot
from mangum import Mangum
from fastapi import FastAPI,Response, Request,BackgroundTasks


# Initialize Flask App
app = FastAPI()

handler = Mangum(app)
# Load .env file
load_dotenv()

Expand All @@ -27,7 +28,7 @@
VERIFY_TOKEN = os.getenv("VERIFY_TOKEN")
PORT= os.getenv("PORT", 8000)

# facebook messenger object
# facebook messenger object
facebook=Bot(os.getenv("PAGE_ACCESS_TOKEN") ,api_version=16.0)

# sarufi object
Expand Down Expand Up @@ -122,7 +123,7 @@ def respond(sender_id: str, message: str, message_type: str = "text"):
return execute_actions(response,sender_id)
except Exception as error:
logging.error(f"{error} in respond")


@app.get("/")
async def webhook_verification(request: Request):
Expand Down Expand Up @@ -169,4 +170,4 @@ async def webhook_handler(request: Request,tasks:BackgroundTasks):


if __name__ == "__main__":
uvicorn.run("main:app",port=PORT)
uvicorn.run("main:app",port=PORT)
28 changes: 23 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
sarufi==0.1.7
pymessenger==0.0.7.0
fastapi==0.97.0
python-dotenv==0.21.0
uvicorn==0.22.0
annotated-types==0.6.0
anyio==3.7.1
certifi==2023.7.22
charset-normalizer==3.3.1
click==8.1.7
fastapi==0.104.0
h11==0.14.0
httpcore==0.18.0
httpx==0.25.0
idna==3.4
pydantic==2.4.2
pydantic-core==2.10.1
python-dotenv==1.0.0
python-multipart==0.0.6
PyYAML==6.0.1
requests==2.31.0
sarufi==0.1.9
schema==0.7.5
sniffio==1.3.0
starlette==0.27.0
urllib3==2.0.7
uvicorn==0.23.2
mangum==0.17.0

0 comments on commit b68802d

Please sign in to comment.