Implementacion mas completa de email y api para ingresar datos
This commit is contained in:
46
entry/api.py
Normal file
46
entry/api.py
Normal file
@ -0,0 +1,46 @@
|
||||
from flask import Flask, redirect, url_for
|
||||
import os
|
||||
from src.instrucciones import Instrucciones
|
||||
import json
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
data_folder = os.path.join(os.path.realpath('..'), 'data')
|
||||
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def index():
|
||||
return {
|
||||
'api': {
|
||||
'entrypoints': {
|
||||
'bosses': [
|
||||
'add',
|
||||
'/'
|
||||
],
|
||||
'instructions': [
|
||||
'add',
|
||||
'/'
|
||||
],
|
||||
'email': []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@app.route('/instructions/', methods=['GET'])
|
||||
def instructions():
|
||||
instrucciones = Instrucciones(data_folder)
|
||||
data = {'Instrucciones': [{'Name': i.instruccion, 'Aliases': i.aliases} for i in instrucciones.instrucciones]}
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
@app.route('/instructions/add/<string:instruccion>/<string:alias>')
|
||||
def add_instruccion(instruccion, alias):
|
||||
ins = Instrucciones(data_folder)
|
||||
ins.add(instruccion, [alias])
|
||||
ins.save()
|
||||
return redirect(url_for('instructions'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(port=8081, debug=True)
|
Reference in New Issue
Block a user