Table of contents
Change password (requires token)
Change avatar (requires token)
Get user list (requires token):
Obtain the file (port 5000) source code file, and the db file cannot be obtained:
Verification token (token required):
File interface (need to use the previous interface to obtain the file to access):
Number of video news and article news (fan chart analysis):
Trend data of the total number of articles within a week (line chart analysis):
Publish news (requires token):
Get all news under the news category:
Get the list published by the user (requires token):
Get the list of user likes (requires token):
API run and postman test diagram:
illustrate:
First release the app written based on the API
Basic instructions
*Some interfaces require a token, that is, add the Authorization field to the header, and the token is obtained by logging in json
Demo api location: 222.187.232.63:39999
Demo file management address: 222.187.232.63:5000
For example, get the news carousel image: http://222.187.232.63:39999/news/banner
other instructions:
The total code volume of front-end and back-end is about 6k lines, which is relatively lightweight.
Token addition: Add Authorization parameter to Head
The response parameter likearray returns an array-like string. You need to manually use the split() function to cut after obtaining it.
Since some data comes from the network and some data comes from the local area, the local path considers portability and does not write the full path. You need to manually determine whether the image contains http:// or https://
Developer Notes:
The front and back ends of this app are completely open source. The front end is written in java android, and the back end uses python. The code size is about 5k, which is relatively lightweight. The
default api address is: 127.0.0.1+port number 39999, and the file access address is: 127.0.0.1+port number 5000.
The ip address and api port number can be modified through /libs/Service_Utils.py.
The backend is written in python and uses the httpserver + Flask framework (main processing files) to process http requests.
Use jwt for dynamic authorization tokens, which need to obtain users, such as likes, Comments need to pass a token to obtain the user.
Most of the data is stored in the sqlite database. Some data, such as announcements, are stored in files to facilitate modification of
python packaged data. It may be a data transmission problem. Sometimes one is missing}. This can be solved through this code. Question
public static String verjson(String jsontext) { try { JSONObject jsonObject=new JSONObject(jsontext); return jsontext; } catch (JSONException e) { return jsontext +"}"; } }
I'm too lazy to change the back-end logic. I can change the password as long as I pass in the token. I need to write verification on the front-end (which is actually not necessary, because generally you can only get the token by logging in).
Next is the API documentation:
Common interface:
Log in:
Interface name:/login
Request method: post
parameter:
username: username
password: password
register:
Interface name:/Reg
Request method: post
parameter:
username: username
password: password
avater: avatar
Change password (requires token)
Interface name:/update_password
Request method: post
parameter:
password: password
Change avatar (requires token)
Interface name:/update_avatar
Request method: post
parameter:
avater: avatar
Get user list (requires token):
Interface name:/personlist
Request method: post
Upload files (port 5000):
Interface name:/upload
Request method: post
parameter:
file: file
Obtain the file (port 5000) source code file, and the db file cannot be obtained:
interface name:/pathname
Request method: get
Verification token (token required):
Interface name:/vertoken
Request method: get
Get system time:
Interface name:/gettime
Request method: get
File interface (need to use the previous interface to obtain the file to access):
announcement:
Interface name:/profile/notfication
Request method: get
App introduction:
Interface name:/profile/instructio
Request method: get
Number of video news and article news (fan chart analysis):
Interface name:/profile/percent
Request method: get
Data on the total score, reading volume, likes, and comments of the top ten video articles (bar chart analysis):
Interface name:/profile/percent
Request method: get
Trend data of the total number of articles within a week (line chart analysis):
Interface name:/profile/trend
Request method: get
New version apk address:
Interface name:/docs/newsapp.apk
Request method: get
News interface:
news list:
Interface name:/news/list
Request method: get
Parameters (default 20 pages):
pagenum : which page to start from
pagenum : display size
Like news (requires token):
Interface name:/news/like
Request method: get
Parameters (default 20 pages):
Id: the id of the news
Unlike news (requires token):
Interface name:/news/unlike
Request method: get
Parameters (default 20 pages):
Id: the id of the news
Publish news (requires token):
Interface name:/news/create
Request method: post
Parameters (if you want to pass the video type, write the video, and content, write the address):
title: title
content: text
type:type
cover:image
Get all news under the news category:
Interface name: news/type=value
Request method: get
Keyword search news:
Interface name: news/search=value
Request method: get
Get hot news:
Interface name: news/hot
Request method: get
Get the carousel image:
Interface name: news/banner
Request method: get
Get the list published by the user (requires token):
Interface name: news/pushlist
Request method: get
Get random videos:
Interface name:/randomvideo
Request method: get
Get the list of user likes (requires token):
Interface name: news/likelist
Request method: get
Get comments:
Interface name: news/likelist
Request method: get
parameter:
Id: ID number of video/news
API run and postman test diagram:
About open source: It will be open source after all the source code is sorted out. You can go to 222.187.232.63:39999 to experience the demo version.
Name and praise
Thanks to the following porters for helping me promote the article
http://element-ui.cn/article/show-1494297.aspx
https://www.ngui.cc/article/show-1153128.html
https://www.lmlphp.com/user/629051
https://www.ppmy.cn/news/628760.html
https://www.lmlphp.com/user/629939/article
Anti-theft:
This article was written by Wen Hui, Software Technology of Fuzhou Vocational and Technical School qq:2151335401,3135144152
Welcome to move, please copy the previous line