Simple image host.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.node.js 658B

12345678910111213141516171819202122232425262728293031323334
  1. module.exports = function(ctx) {
  2. var id = parseInt(ctx.req.url.split("?")[1]);
  3. if (isNaN(id))
  4. return ctx.end(ctx.view("404"));
  5. ctx.db.query(
  6. "SELECT id, name, description, extension "+
  7. "FROM images "+
  8. "WHERE collection_id = $1",
  9. [id],
  10. queryCallback
  11. );
  12. function queryCallback(err, res) {
  13. if (err)
  14. return ctx.fail(err);
  15. var images = "";
  16. res.rows.forEach(function(row) {
  17. images += ctx.template("image", {
  18. title: row.name,
  19. id: row.id,
  20. extension: row.extension,
  21. description: row.description
  22. });
  23. });
  24. ctx.end(ctx.view("view", {
  25. profile: ctx.template("navbar-profile-login"),
  26. images: images
  27. }));
  28. }
  29. }