-
Notifications
You must be signed in to change notification settings - Fork 0
/
aydaapi3.py
30 lines (24 loc) · 924 Bytes
/
aydaapi3.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
from flask import Flask
from flask.ext.restless import APIManager
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
#test
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///people.db'
app.config['DEBUG'] = True
db = SQLAlchemy(app)
class Person(db.Model):
id = db.Column(db.Integer, primary_key=True)
first_name = db.Column(db.Text)
last_name = db.Column(db.Text)
class Datapoints(db.Model):
id = db.Column(db.Integer, primary_key=True)
person_id = db.Column(db.Integer, db.ForeignKey(Person.id))
date = db.Column(db.Text)
basal_temperature = db.Column(db.Text)
days_since_period_began = db.Column(db.Integer)
db.create_all()
api_manager = APIManager(app, flask_sqlalchemy_db=db)
api_manager.create_api(Person, methods=['GET', 'POST', 'DELETE', 'PUT'])
api_manager.create_api(Datapoints, methods=['GET', 'POST', 'DELETE', 'PUT'])
if __name__ == "__main__":
app.run()