A simple custom API using Python + Flask + Postgresql
Demo Website which uses this backend: CSGeeks Blog
Also checkout the Android App made by my friend Avadhoot
and the FrontEnd CSGeeksBlog made by me(JayPowar)
(understand the code before running it blindly)
The app.py is like a skeleton!
don’t try to run it without modiying it…
you have to enter your own credentials for the postgresql database…
there are some values indicated by <> , inside which you have supposed to fillup the particular data…
(Created some temporary GET route for posting form data quickly!)
don’t except 100% output without modiying it…
This gets all the data from given table of from the database and return it in json format (array of objects)
e.g. looks like this…
{
"users" : [
{
"name":"user1",
"email": "user1@example.com"
},
{
"name":"user2",
"email": "user2@example.com"
}
]
}
this route also includes advanced queries!
(These queries can be combined together for more accuracy in response as per required!)
for admin previleges, must login for performing some adding or deleting posts operations !(from api site)
Will insert the Title, Author, Content, Description, Tags, Thumbnail data into posts Table!
i.e. it will create a new Article!
Required fields for creation of post:
type -> form data
query parameter:
This route will fetch data for single post of mentioned _id from the database…
Added feature for logging in via header request (C_AUTH) with particular key value !
(if working on cross-domain/cross-site it will give only one time access, so would’ve to use it with all requests!)
This will delete all posts from db
query parameters:
This route will give information about author if ‘name’ query parametr is given to this route.
query parameters:
This will update the data values from the existing post of given ‘id’ parameter.
query parameters:
Required fields for updation of post of given id:
(only give the params which needs to be updated from post with given id other data will reamain as it is!)
type -> form data
query parameter:
This is used for authentication, as it sounds it performs login of particular user and generates a jwt token which can be used to access routes like /blog/create
and /blog/update
without any auth-header (token will expire after 1 day)
query parameter:
This is used to check if the user is logged in or not(obviously will need help of jwt token)
query parameter:
{
"response":"Not Logged In!(ps:token is missing)",
"success":false
}
This is still under developement …