-
Notifications
You must be signed in to change notification settings - Fork 0
/
wiproms.py
executable file
·35 lines (24 loc) · 1 KB
/
wiproms.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
26
27
28
29
30
31
32
33
34
35
import flask
import flask_sqlalchemy
import flask_restless
app = flask.Flask(__name__)
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = flask_sqlalchemy.SQLAlchemy(app)
class Events(db.Model):
id = db.Column(db.Integer, primary_key=True)
group = db.Column(db.Integer)
description = db.Column(db.String(128))
class Branches(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Unicode, unique=True)
db.create_all()
manager = flask_restless.APIManager(app, flask_sqlalchemy_db=db)
manager.create_api(Events, methods=['GET', 'POST'])
manager.create_api(Branches, methods=['GET'])
if __name__ == '__main__':
app.run(debug=True)
# curl -i -H "Content-Type: application/json" -X POST -d '{"group": 5, "description": "just testing"}' http://localhost:5000/api/events
# curl -i http://localhost:5000/api/events
# curl -i http://localhost:5000/api/events/1