This is a simple REST API project using the Python framework Flask. The password generator is using my other project, which you can find it here.
You have 2 options to run this project in your own environment:
- Docker (Recommended)
- Python
-
Make sure you have docker installed on your machine. Use this guide to get started.
-
Clone the repository:
git clone https://github.com/hamedp77/password-api.git
-
Make sure you're in the root directory of the project:
cd password-api
-
Build the docker image and tag it:
docker build . -t password-api
-
Run the container and publish port
80
of the container to an open port on your local machine, e.g., port5000
:docker run -p 5000:80 password-api
-
Open
http://localhost:5000
to make sure everything is running.
-
Make sure you have Python installed on your machine. You can download and install the latest version of Python from here.
-
Clone the repository:
git clone https://github.com/hamedp77/password-api.git
-
Make sure you're in the root directory of the project:
cd password-api
-
Install dependencies:
pip install -r requirements.txt
-
To run in a "development" environment you can use:
flask --app api run
or
python api.py
These commands will run the application on
http://localhost:5000
with debug mode disabled by default. The easiest way to enable debug mode is to set theFLASK_DEBUG
environment variable totrue
.Note: Using a WSGI server like gunicorn is the preferred way of running this in a "production" environment. If you have been following along with these steps, you have gunicorn already installed. All you have to do is run this command:
gunicorn -b 0.0.0.0:80 api:app
This will expose the API on all the available network interfaces of your machine on port
80
.
If you visit the URL of your deployed application, you'll be automatically redirected to the documentation page of the API, which is a Swagger UI. Here you can see all the details of each endpoint, how you can send requests to them, and the expected responses. You can also try each endpoint using the "try it out" button in your browser.