From 4c060e6a4e02bf3be5272c0ac7d4bddd2836aa03 Mon Sep 17 00:00:00 2001 From: Li-Nathaniel <124535876+Li-Nathaniel@users.noreply.github.com> Date: Sat, 30 Mar 2024 14:13:56 -0400 Subject: [PATCH] Initial creation (#3) --- api_template/Data/README.md | 1 + api_template/README.md | 7 +++++++ api_template/Schemas/README.md | 1 + api_template/main.py | 13 +++++++++++++ api_template/requirements.txt | 1 + 5 files changed, 23 insertions(+) create mode 100644 api_template/Data/README.md create mode 100644 api_template/README.md create mode 100644 api_template/Schemas/README.md create mode 100644 api_template/main.py create mode 100644 api_template/requirements.txt diff --git a/api_template/Data/README.md b/api_template/Data/README.md new file mode 100644 index 0000000..b0f7486 --- /dev/null +++ b/api_template/Data/README.md @@ -0,0 +1 @@ +This folder is optional but if you have any data (eg. CSV) files that are needed, you should store them here in one folder \ No newline at end of file diff --git a/api_template/README.md b/api_template/README.md new file mode 100644 index 0000000..a57f12e --- /dev/null +++ b/api_template/README.md @@ -0,0 +1,7 @@ +# API Template (Flask) + +This is a template you can use/follow to make a simple Flask Microservice. It may need adjusting based on your needs. + +Simply put, you should be able to use this template by importing your original python file and modifying the other files/folders to setup the API endpoints. + +For more guidance, you can also refer to the ETA API for more guidance as that follows a very similar format. \ No newline at end of file diff --git a/api_template/Schemas/README.md b/api_template/Schemas/README.md new file mode 100644 index 0000000..d58fb8b --- /dev/null +++ b/api_template/Schemas/README.md @@ -0,0 +1 @@ +This Schemas folder should contain any SQL queries needed to setup your table so that it can receive data \ No newline at end of file diff --git a/api_template/main.py b/api_template/main.py new file mode 100644 index 0000000..d0c9a7b --- /dev/null +++ b/api_template/main.py @@ -0,0 +1,13 @@ +# This file will be heavily dependent on your service but some general steps are detailed below + +# Ensure that any dependencies (eg. libraries, packages, files, DB) are accounted for here + +# Retrieve environment variables (ie. DB credentials) and connect to your DB + +# Write your API methods/endpoints below as needed (this should take care of pulling data and writing it as needed through the use of JSON data) + +# Your API method can most likely pull the necessary data, feed it into your logic/other python file (eg. for the ETA API, it feeds the data into the eta.py file, and execute the appropriate methods + +# Below is the code needed to start running your microservice -> The code below will run your microservice locally on port 6000 (change as necessary if it's already taken) +if __name__ == '__main__': + app.run(host='0.0.0.0', port=6000) \ No newline at end of file diff --git a/api_template/requirements.txt b/api_template/requirements.txt new file mode 100644 index 0000000..650e465 --- /dev/null +++ b/api_template/requirements.txt @@ -0,0 +1 @@ +This file is pretty straightforward, make sure to have all required packages/libraries included here for setup/dependency purposes. \ No newline at end of file