-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (30 loc) · 1016 Bytes
/
app.py
File metadata and controls
38 lines (30 loc) · 1016 Bytes
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
36
37
38
from flask import Flask
from flask_jwt import JWT
from flask_restful import Api
from resources.items import ItemResource, ItemList
from resources.users import UserRegister
from security import authenticate, identity
from db import db
from models.users import User
from models.items import Item
apple = Flask(__name__)
api = Api(apple)
apple.config['SECRET_KEY'] = 'super-secret'
jwt = JWT(apple, authenticate, identity)
db.init_app(apple)
apple.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
apple.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
@apple.before_first_request
def create():
db.create_all()
# user = User(username='anatolii', password='123')
# db.session.add(user)
#
# item = Item(item_name='I want banana too', price='123')
# db.session.add(item)
# db.session.commit()
api.add_resource(ItemResource, '/items/<string:name>')
api.add_resource(ItemList, '/items')
api.add_resource(UserRegister, '/register')
if __name__ == '__main__':
apple.run(debug=True)