Init
This commit is contained in:
commit
ed79985fba
5 changed files with 83 additions and 0 deletions
30
.drone.yml
Normal file
30
.drone.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: generate
|
||||
image: knovus/drone-openfaas
|
||||
settings:
|
||||
template: python3-http
|
||||
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
username:
|
||||
from_secret: docker_registry_user
|
||||
password:
|
||||
from_secret: docker_registry_pass
|
||||
registry: registry.serguzim.me
|
||||
repo: registry.serguzim.me/faas/${DRONE_REPO_NAME}
|
||||
context: ./build/${DRONE_REPO_NAME}/
|
||||
dockerfile: ./build/${DRONE_REPO_NAME}/Dockerfile
|
||||
tags: latest
|
||||
|
||||
- name: deploy
|
||||
image: knovus/drone-openfaas
|
||||
settings:
|
||||
deploy: true
|
||||
url: https://faas.serguzim.me
|
||||
password:
|
||||
from_secret: openfaas_password
|
||||
registry: registry.serguzim.me
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
build/
|
||||
template/
|
39
src/handler.py
Normal file
39
src/handler.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
from bs4 import BeautifulSoup
|
||||
import numpy as np
|
||||
import requests
|
||||
|
||||
def handle(event, context):
|
||||
|
||||
page = requests.get('https://courses.wiso.uni-tuebingen.de/matrix/matrix-of-the-day')
|
||||
|
||||
soup = BeautifulSoup(page.text, 'html.parser')
|
||||
|
||||
matrix_tag = soup.find_all('div', class_='matrix')[0].contents
|
||||
matrix_msg = matrix_tag[1].contents[0]
|
||||
matrix_split = matrix_tag[2].split('\n')
|
||||
|
||||
while '' in matrix_split:
|
||||
matrix_split.remove('')
|
||||
|
||||
for i in range(len(matrix_split)):
|
||||
char = matrix_split[i]
|
||||
if char == '&':
|
||||
matrix_split[i] = ' '
|
||||
if char == '\\\\':
|
||||
matrix_split[i] = ';'
|
||||
|
||||
a = np.matrix(''.join(matrix_split[1:-1]).rstrip(';'))
|
||||
|
||||
result = {}
|
||||
|
||||
result['message'] = matrix_msg
|
||||
result['matrix'] = str(a)
|
||||
result['determinant'] = np.linalg.det(a)
|
||||
|
||||
return {
|
||||
"statusCode": 200,
|
||||
"body": result,
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
}
|
3
src/requirements.txt
Normal file
3
src/requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
beautifulsoup4==4.9.3
|
||||
numpy==1.20.1
|
||||
requests==2.25.1
|
9
stack.yml
Normal file
9
stack.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
provider:
|
||||
name: openfaas
|
||||
gateway: https://faas.serguzim.me
|
||||
|
||||
functions:
|
||||
determinant-of-the-day:
|
||||
lang: python3-http
|
||||
handler: ./src
|
||||
image: registry.serguzim.me/faas/determinant-of-the-day
|
Loading…
Reference in a new issue