PyBlog is a FastAPI application for managing a simple blog system with user authentication and post management features.
- Accepts
email
andpassword
. - Returns a token (JWT or randomly generated string).
- Accepts
email
andpassword
. - Returns a token upon successful login; error response if login fails.
- Accepts
text
and atoken
for authentication. - Validates payload size (limit to 1 MB), saves the post in memory, returning
postID
. - Returns an error for invalid or missing token.
- Dependency injection for token authentication.
- Requires a token for authentication.
- Returns all user's posts.
- Implements response caching for up to 5 minutes for the same user.
- Returns an error for invalid or missing token.
- Dependency injection for token authentication.
- Accepts
postID
and atoken
for authentication. - Deletes the corresponding post from memory.
- Returns an error for invalid or missing token.
- Dependency injection for token authentication.
- Uses in-memory caching for "GetPosts" to cache data for up to 5 minutes, employing tools like
cachetools
for this purpose. - Ensures the implementation of both SQLAlchemy and Pydantic models for each endpoint includes extensive type validation to guarantee the accuracy and integrity of data being processed.
-
Clone the repository:
git clone https://github.com/your_username/pyblog.git
-
Install the Dependencies:
pip install -r requirements.txt
-
Create MySQL databse:
- Create a MySQL database and user (if not already done) and update database.py with your MySQL database configuration.
- Create a .env file in your project directory.
- Add your secret key variables to the .env file.
-
Run the Application:
python app/main.py
-Access the API at http://localhost:8000 in your browser.