30 lines
742 B
Python
30 lines
742 B
Python
from flask import Flask
|
|
from flask_restful import Api
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
app = Flask(__name__)
|
|
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
|
|
db = SQLAlchemy(app)
|
|
api = Api(app)
|
|
|
|
|
|
def init_db():
|
|
from vcinema.models.room import Room
|
|
from vcinema.models.user import User
|
|
db.create_all()
|
|
|
|
def init_resources():
|
|
from vcinema.resources.rooms import RoomApi, RoomsApi
|
|
from vcinema.resources.users import UsersApi
|
|
api.add_resource(RoomApi, "/rooms/<id>")
|
|
api.add_resource(RoomsApi, "/rooms")
|
|
api.add_resource(UsersApi, "/users")
|
|
# api.add_resource(UserAPI, "/users/<id>")
|
|
|
|
def main():
|
|
init_db()
|
|
init_resources()
|
|
app.run(debug=True)
|
|
|
|
if __name__ == "__main__":
|
|
main() |