From 079e15f6ff9c715f0027422ea149944e527065b3 Mon Sep 17 00:00:00 2001 From: Jonas Duarte Date: Wed, 7 Jul 2021 00:48:08 -0300 Subject: [PATCH] Featured: #1. Inicializada estrutura da API --- commons/db/create.sql | 1 + commons/db/create_tables.sql | 0 requirements.txt | 3 +++ resources/__init__.py | 1 + resources/pedidos/__init__.py | 19 +++++++++++++++++++ server.py | 24 ++++++++++++++++++++++++ 6 files changed, 48 insertions(+) create mode 100644 commons/db/create.sql create mode 100644 commons/db/create_tables.sql create mode 100644 requirements.txt create mode 100644 resources/__init__.py create mode 100644 resources/pedidos/__init__.py create mode 100644 server.py diff --git a/commons/db/create.sql b/commons/db/create.sql new file mode 100644 index 0000000..6c700a2 --- /dev/null +++ b/commons/db/create.sql @@ -0,0 +1 @@ +create database `duzz-pedidos`; \ No newline at end of file diff --git a/commons/db/create_tables.sql b/commons/db/create_tables.sql new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b535013 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +flask +flask_restful +flask_cors \ No newline at end of file diff --git a/resources/__init__.py b/resources/__init__.py new file mode 100644 index 0000000..808dd74 --- /dev/null +++ b/resources/__init__.py @@ -0,0 +1 @@ +from resources.pedidos import Pedidos \ No newline at end of file diff --git a/resources/pedidos/__init__.py b/resources/pedidos/__init__.py new file mode 100644 index 0000000..a73851a --- /dev/null +++ b/resources/pedidos/__init__.py @@ -0,0 +1,19 @@ +from flask_restful import Resource + +class Pedidos(Resource): + def get(self): + return { + 'codigo': 1 + } + + + def put(self): + pass + + + def post(self): + pass + + + def delete(self): + pass \ No newline at end of file diff --git a/server.py b/server.py new file mode 100644 index 0000000..3c2bd60 --- /dev/null +++ b/server.py @@ -0,0 +1,24 @@ +from logging import debug +from flask import Flask +from flask_restful import Api +from flask_cors import CORS + +from resources import ( + Pedidos +) + +app = Flask(__name__) +CORS(app) +api = Api(app) + + +@app.route('/') +def index(): + return """ +

Hello World! + """ + +api.add_resource(Pedidos, '/pedidos') + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file