File size: 613 Bytes
0c3de86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
import flask
import flask_cors
import os

messageArray = {}

# sets up the app
app = flask.Flask(__name__)
flask_cors.CORS(app)

# creates a API endpoint for the password input
@app.route('/messages', methods=['POST'])
def password():
    nameIn = flask.request.get_json()['nameInput']
    messageIn = flask.request.get_json()['messageInput']

    n = len(messageArray)
    
    messageArray.update({"message "+str(n): [nameIn, messageIn]})
    
    data = {
        'messages': messageArray
    }
    
    return flask.jsonify(data)




if __name__ == "__main__":
    app.run(debug=True,host="0.0.0.0",port=5000)