- Install NodeJS 和 MongoDB
- Upload
back-end/nodejs/*
- Run in
nodejs
:
$ npm install
$ nohup node index.js &
- Change
js/like.js
url:8888/api/like?action=add
url:8888/api/like?action=get
- Enjoy it!
- Create a mysql table, run sql:
CREATE TABLE IF NOT EXISTS `votes` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`likes` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `votes` (`id`, `likes`) VALUES
(1, 0);
CREATE TABLE IF NOT EXISTS `votes_ip` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`vid` int(10) NOT NULL,
`ip` varchar(40) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
- Fill out database information in
like.php
- Upload
like.php
- Enjoy it!
See demo
MIT © DIYgod