repl.it
@functorflow/

report-issue

Python

No description

fork
loading
Files
  • main.py
  • settings.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from flask import Flask, jsonify, request
from functorflow import ff

from settings import CRUD_ADDR

app = Flask('app')

crud = ff.crud.new(address=CRUD_ADDR)
issues = crud.read('issues') 
index = len(issues) if issues else 0 # initialize the index

@app.route('/', methods=['POST'])
def post_issue():
  global index
  new_issue = request.get_json()
  resp = crud.create('issues', index, new_issue)
  index += 1
  return jsonify(resp)

@app.route('/', methods=['GET'])
def get_issue():
  issues = crud.read('issues')
  return jsonify(issues)

app.run(host='0.0.0.0', port=8080)