https://github.com/peliah/basic-python-api
This is a simple public API that returns basic information in JSON format.
https://github.com/peliah/basic-python-api
api flask python
Last synced: 2 months ago
JSON representation
This is a simple public API that returns basic information in JSON format.
- Host: GitHub
- URL: https://github.com/peliah/basic-python-api
- Owner: Peliah
- Created: 2025-01-30T23:09:52.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-31T00:13:16.000Z (over 1 year ago)
- Last Synced: 2025-01-31T00:25:21.510Z (over 1 year ago)
- Topics: api, flask, python
- Language: Python
- Homepage: https://hng-12-api.onrender.com/
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
# **Basic Python API with FastAPI**
This is a simple public API built with **FastAPI** that returns basic information in JSON format. The API provides the following details:
- Your registered email address.
- The current datetime in ISO 8601 format (UTC).
- The GitHub URL of the project's codebase.
---
## **Features**
- **FastAPI**: A modern, fast (high-performance) web framework for building APIs with Python.
- **CORS Support**: Handles Cross-Origin Resource Sharing (CORS) to allow requests from any domain.
- **Caching**: Uses `lru_cache` to cache the response for improved performance.
- **Deployment**: Deployed on **Render** for public access.
---
## **API Documentation**
### **Endpoint**
- **URL**: `https://hng-12-api.onrender.com/`
- **Method**: `GET`
### **Response Format**
```json
{
"email": "pelepoupa@gmail.com",
"current_datetime": "2023-10-10T12:34:56.789Z",
"github_url": "https://github.com/Peliah/basic-python-api"
}
```
---
## **Setup Instructions**
### **1. Clone the Repository**
```bash
git clone https://github.com/Peliah/basic-python-api.git
cd basic-python-api
```
### **2. Install Dependencies**
Ensure you have Python 3.7+ installed. Then, install the required dependencies:
```bash
pip install -r requirements.txt
```
### **3. Run the Application Locally**
Start the FastAPI app using Uvicorn:
```bash
uvicorn main:app --host 0.0.0.0 --port 8000
```
Visit `http://127.0.0.1:8000/` in your browser or use `curl` to test the API:
```bash
curl http://127.0.0.1:8000/
```
---
## **Deployment**
This API is deployed on **Render**. To deploy your own instance:
1. **Sign Up on Render**: Go to [Render](https://render.com) and create an account.
2. **Create a New Web Service**:
- Connect your GitHub repository.
- Set the **Start Command** to:
```bash
uvicorn main:app --host 0.0.0.0 --port 8000
```
3. **Deploy**: Render will automatically build and deploy your application.
---
## **Example Usage**
### **Request**
```bash
curl https://hng-12-api.onrender.com/
```
### **Response**
```json
{
"email": "pelepoupa@gmail.com",
"current_datetime": "2023-10-10T12:34:56.789Z",
"github_url": "https://github.com/Peliah/basic-python-api"
}
```
---
## **Technologies Used**
- **FastAPI**: A modern, fast web framework for building APIs.
- **Uvicorn**: A lightning-fast ASGI server for serving FastAPI apps.
- **Render**: A cloud platform for deploying web services.
---
## **License**
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
---
## **Backlink**
- [Hire Python Developers](https://hng.tech/hire/python-developers)
---
## **Contact**
For questions or feedback, please contact:
- **Email**: pelepoupa@gmail.com
- **GitHub**: [Peliah](https://github.com/Peliah)
---
🚀