Skip to content
/ Arya Public

Api server for my static blog comments system

License

Notifications You must be signed in to change notification settings

yydai/Arya

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API server for my blog comments system

Why?

I use github issues to manage my blog’s comments and this is the background.

API server is used for creating a new issue for my blog comment.

The POSΤ request can’t sent to github from github pages because it doesn’t suppport CORS. Thus, I create an api server as a springboard.

In addition, you can find the implement of my static comments system here.

Usage

You can use this as your api server and it’s domain is:

https://blog-api-server.herokuapp.com/

If you want to use this, you need to send a GET request to the url of:

https://blog-api-server.herokuapp.com/issues

You also need to provide the data of:

title labels body owner repo auth

for example:

https://blog-api-server.herokuapp.com/issues?title=test&labels=blog&body=Welcome to leave comments here.&owner=yydai&repo=yydai.github.io&auth=<base64(username:password)>

Note: The username and password is github account.

Also, you can setup your own api server.

What to do?

./imgs/20170629_182003_37318ybz.png

API

The endpoint is:

https://{hostname}/blog/api/v1/

The API of our service:

HTTP MethodURLAction
GET{endpoint}/issues
POSThttps://api.github.com/repos/{owner}/{repo}/issuescreate an issue

GEΤ Parameters:

NameTypeDescription
titlestringRequired. The title of the blog.
labelsstringRequired. Default is “blog”.
bodystringThe contents of the issue. Default is “Welcome to leave comments here.”.
ownerstringRequired. The owner of the repo. Default is “yydai”
repostringRequired. The repo name. Default is “yydai.github.io”
authstringRequired. the base64(username:password)

Example:

{endpoint}/issues?title=This is a test&labels=blog&body=Welcome to leave comments here.&owner=yydai&repo=yydai.github.io

POSΤ Parameters:

NameTypeDescription
titlestringRequired. The title of the issue.
labelsstringRequired. Label to associate with this issue.
bodystringThe contents of the issue.

Example:

https://api.github.com/repos/yydai/yydai.github.io/issues

{
    "title": "This is a test",
    "body": "Welcome to leave comments here.",
    "labels": ["blog"]
}

Implement

I will use Flask to do this job. tutorials1 and tutorials2.

In this phase, Our goal is just to implement the api above.

You can view the code in app.py.

Deployment

I will use the Heroku to deploy this api server.

If you want to use Heroku to deploy flask application, you need to include the following files:

  • Procfile
  • requirements.txt

Check the documentation of Python here if necessary.

Using the following command to get the requirements.txt.

pip freeze > requirements.txt

In this project, my Procfile:

web gunicorn <app>:app

About

Api server for my static blog comments system

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages