REST API using Flask and Python [Air connections search]
Project consist of:
- images - folder with images sources
- tests - folder with UnitTests, Pytest
- app.py - main application resource
- db.py - resource for creation and for fill the database
- requirements.txt - file for install packages
- list.csv - list of flights for database
- pytest.ini - pytest file
- config.cfg - file with config, flake8
For using application you need to do:
- Install Python 3.6 or higher
- Install requirements
- pip install -r requirements.txt
- Create database for application
- python db.py
$ python db.py
20 Record Transferred
- There are 3 environments to choose from with different databases, choose one:
- testing - for local testing,
- dev - need to be configured manually
- prod - need to be configured manually
- Run application
- python app.py testing
$ python app.py
* Serving Flask app "app" (lazy loading)
* Environment: production
* Debug mode: on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 231-078-686
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
- Follow the link http://127.0.0.1:5000/
Endpoints
| Endpoint | Request | Description |
|---|---|---|
| /flight | GET | Get All Flights |
| /flight/id | GET | Get Single Flight |
| /flight | POST | Create a Flight |
| /flight/id | PUT | Update a Flight |
| /flight/id | DELETE | Delete Flight |
| /flight/search | GET | Flight search between 2 cities |
Start Using:
1. Get All Flights
curl -X GET http://127.0.0.1:5000/flight
2. Get Single Flight
curl -X GET http://127.0.0.1:5000/flight/10
3. Create a Flight
curl -X POST -H "Content-Type: application/json" -d '{"source": "Barcelona", "destination": "Palma de Mallorca", "flight_company": "Vueling", "flight_number": "FR3745", "flight_time": "55m", "free_seats": "5", "price": "50$"}' http://127.0.0.1:5000/flight
4. Update a Flight
curl -X PUT -H "Content-Type: application/json" -d '{"source": "Barcelona", "destination": "Palma de Mallorca", "flight_company": "Ryanair", "flight_number": "FR3785", "flight_time": "50m", "free_seats": "8", "price": "150$"}' http://127.0.0.1:5000/flight/11
5. Delete Flight
curl -X DELETE http://127.0.0.1:5000/flight/11
6. Flight search between 2 cities
http://127.0.0.1:5000/flight/search?c1=Milan&c2=Barcelona
UnitTests:
Download the project:
- Follow the link
- Choose branche (feature/jdobc-255)
- Using Linter
- Install packages
pip install flake8
- Run flake8
flake8
$ flake8
0
- Using PyTest
- Install pytest from pip
pip install pytest
- Run pytest
pytest -v
- Coverage by PyTest:
- Install packages
pip install pytest-cov
- Run command
pytest --cov=. --cov-config='.coveragerc' -c='pytest.ini'
GitLab CI Multi-project:
- Flake8
- Pytest
- Coverage
- Build artifact
- Upload artifact to s3
- Deploy terraform code
Logging for AWS CloudWatch
- How to run the application locally in the test environment ?
- run applicatin:
python app.py testing- Log output file "air-connection-app.log" will be created automatically
- То see the streaming of application logs in AWS you need to deploy the application in AWS using terraform template and go to CloudWatch logs
Metadata
Release files for python-app 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_app-0.1.tar.gz | 5.9 kB | Without provenance | Details for python_app-0.1.tar.gz |
Release files / python_app-0.1.tar.gz
| Download URL | python_app-0.1.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec8d9539807c4c90d3d454d3e0ea636887c07b364e0dee17836694b132937b72
|
|
BLAKE2b-256 checksum How to use checksums |
775e2f9df8d2055e2a9cd372abd9e7e73c292957da769c0571f7abee0b56350d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2
|
Security for python-app 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.