Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amicks/cruzhacks19-dev-app
REST API Hacker Model for CruzHacks 2019 developer application
https://github.com/amicks/cruzhacks19-dev-app
Last synced: 14 days ago
JSON representation
REST API Hacker Model for CruzHacks 2019 developer application
- Host: GitHub
- URL: https://github.com/amicks/cruzhacks19-dev-app
- Owner: amicks
- License: mit
- Created: 2018-05-17T20:47:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T02:05:46.000Z (about 2 years ago)
- Last Synced: 2024-10-19T17:29:50.478Z (3 months ago)
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CruzHacks19-Dev-App
First install dependencies:``` bash
pip3 install -r requirements.txt
```Then export your SQL database URI as an environment variable for Flask SQLAlchemy hooks.
The following are examples for MySQL, Postgres, and SQLite:``` bash
export SQLALCHEMY_DATABASE_URI='mysql+pymysql://user:password@localhost:port/db_name'
export SQLALCHEMY_DATABASE_URI='postgresql://user:password@localhost:port/db_name'
export SQLALCHEMY_DATABASE_URI='sqlite:////path/db_name.db'
```Start the Flask Server:
``` bash
python3 ./src/app.py
```You can now GET, POST, PUT, or DELETE from the Hacker DB model on the route `http://localhost:5000/hackers/`
Read ./src/api.py for arguments and types that each type of request accepts. In general, everything except GET requires a `public_id` integer. GET can filter the DB model on any categories.There is a test.py file that POSTs 5 users and prints the response if you want to run it in another shell.
Or POST manually (the following arguments are *required* for any POST, there are more optional ones in the source code):``` bash
curl -H "Content-Type: application/json" -d '{"age": 20, "email": "[email protected]", "first_name": "Allston", "last_name": "Mickey", "shirt_size": "M", "needs_transportation": true}' http://localhost:5000/hackers/
```Response:
``` bash
{
"public_id": 6629,
"team_id": null,
"first_name": "Allston",
"last_name": "Mickey",
"email": "[email protected]",
"gender": null,
"age": 20,
"needs_transportation": true,
"rsvp_status": null,
"app_status": null,
"shirt_size": "M",
"university": null,
"class_year": null
}
```