API : first shot

This commit is contained in:
MaelREBOUX 2021-03-27 22:55:40 +01:00
parent ad461ec477
commit 98247dc94c
5 changed files with 52 additions and 0 deletions

11
api/README.md Normal file
View file

@ -0,0 +1,11 @@
# OpenStreetMap & Ar Redadeg
## Installation
cd api
python3 -m venv venv
. venv/bin/activate
pip install Flask

28
api/ar-redadeg.py Normal file
View file

@ -0,0 +1,28 @@
import subprocess
from subprocess import Popen, PIPE
from subprocess import check_output
from flask import Flask
def hello():
stdout = check_output(['./hello.sh']).decode('utf-8')
return stdout
app = Flask(__name__)
@app.route('/',methods=['GET',])
def home():
return '<pre>'+hello()+'</pre>'
@app.route('/phase_1/',methods=['GET',])
def phase1():
stdout = '<pre>'+check_output(['../scripts/traitements_phase_1.sh']).decode('utf-8')+'</pre>'
return stdout
app.run(debug=True)

7
api/hello.py Normal file
View file

@ -0,0 +1,7 @@
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'

3
api/hello.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo "hi from shell script"
echo "hello from shell script"

3
scripts/hello.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo "hi from shell script"
echo "hello from shell script"