News and publishing system source code

Source: Internet
Author: User

News and publishing system source code

① The homepage is index. All news types and news entries are listed here.

② Each news entry has three buttons: Edit, delete, and view.

③ The homepage has a button for adding News (images can be uploaded when adding News)

The basic functions are as follows:

So we removed the routing function in the app and put all the routes in the index.

// Add the routing function to index // app. get ('/', routes. index); // app. get ('/users', user. list); routes (app );
Module. exports = function (app) {// homepage, which is now also the homepage app. get ('/', function (req, res) {res. render ('index', {title: 'express '}) ;}); app. get ('/add', function (req, res) {res. send ('add news requests');}); app. get ('/delete', function (req, res) {res. send ('delete a news request');}); app. get ('/view', function (req, res) {res. send ('view news requests');}); app. get ('/Update', function (req, res) {res. send ('modify news requests ');});};

The first step is as simple as this. Because there should be a separate page for adding news, and there will be additional processing for clicking the Add button, you have to subscribe each request internally. The rules are as follows:

/Default page. All types and news are displayed, with the delete button.

/Add To Go To The add news page

/AddNews Add the specific post request address of the News (response when the button is clicked)

/Delete: delete a news request

/View specific news Query

Then modify the preceding route slightly:

Module. exports = function (app) {// homepage, which is now also the homepage app. get ('/', function (req, res) {res. render ('index', {title: 'express '}) ;}); app. get ('/add', function (req, res) {res. send ('add news page');}); app. post ('/addnew', function (req, res) {res. send ('process and add news requests');}); app. get ('/delete', function (req, res) {res. send ('delete a news request');}); app. get ('/view', function (req, res) {res. send ('view news requests ');});};

Therefore, we need to create several templates to organize our webpage. Here we will not separate the header and tail as long as the simplest page.

Add and view template files are added, which are consistent with index. ejs and are related to modifying navigation.

Module. exports = function (app) {// homepage, which is now also the homepage app. get ('/', function (req, res) {res. render ('index', {title: 'express '}) ;}); app. get ('/add', function (req, res) {res. render ('add', {title: 'add news page'}) ;}); app. post ('/addnew', function (req, res) {res. send ('process and add news requests');}); app. get ('/delete', function (req, res) {res. send ('delete a news request');}); app. get ('/view', function (req, res) {res. render ('view', {title: 'view news requests '});});};

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.