GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - educoder/Pikachu: RESTful service for uploading pictures (and other media)

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
public
public
 
 
tmp
tmp
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
app.js
app.js
 
 
package.json
package.json
 
 
upload.html
upload.html
 
 

Repository files navigation

Pikachu

A tiny RESTful service for uploading pictures and other media.

Local Deployment

git clone git://github.com/educoder/Pikachu.git
cd Pikachu
npm install
node app.js

Pikachu should now be running on http://localhost:2596.

Server Deployment

Deploying on a server isn't much different from local deployment. The main difference is to ensure that Pikachu is automatically started on server start and restart should it crash.

For node.js you can use [forever] (https://github.com/foreverjs/forever), [supervisor] (http://supervisord.org/) or [PM2] (https://github.com/Unitech/PM2). The goal is to have a monitor that starts the node.js based app and keeps it running. Then you use Apache2 or Nginx as a reverse proxy to direct web traffic to the node.js app. At Encore Lab we used forever and then quickly switched to forever.

Another elegant solution is to use [Phussion Passenger] (https://www.phusionpassenger.com/) to run node, Rack and Python based applications. Passenger can run stand alone and offers plugins for Apache2 and Nginx. The major benefit of passenger as a plugin is that any Passenger based app will run when the webserver runs.

If you deploy Pikachu with Passenger on Nginx, the pictures are servered by nginx directly from the public folder without involving passenger nor Pikachu. Serving static content via nginx should improve the performance of Pikachu since nginx deals very well with static content and employs caching strategies to be very efficient.

More details on how to install will follow.

Usage

See http://localhost:2596/upload.html for an example of how to upload to Pikachu using HTML + AJAX.

All files are uploaded to Pikachu's public directory. Any file in public is automatically served at http://localhost:2596. For example public/1234.gif would be accessible at http://localhost:2596/1234.gif.

Pikachu's REST API is as follows:

GET /

Responds with a JSON array listing all files in public.

For example:

[
  "14o241fsc8w.jpg",
  "8q5u9haf40.jpg",
  "qri7bl5clc.jpg"
]

POST /

Uploads a new file to the public directory. Expects a multipart/form-data request (i.e. an HTML form submission or JavaScript FormData) with a key (name) of file.

Responds with JSON. If the upload fails, you'll get a 5xx or 4xx status code and an error object like:

{
  "errno":3,
  "code":"EACCES",
  "path":"/tmp/3b328623fa95f311a3389df247eaa164.jpg"
}

If it succeeds, you'll get a 2xx status code and a body with something like:

{
  "url":"2fr2ursgglc.jpg",
  "size":31511,
  "type":"image/jpeg"
}

See https://github.com/educoder/Pikachu/blob/master/upload.html for a JavaScript example.

GET /<filename>.<ext>

Responds with the contents of the given filename.

For example, GET /14o241fsc8w.jpg would respond with the contents of the public/14o241fsc8w.jpg file. The response's MIME type is automatically resolved based on the file's extension.

About

RESTful service for uploading pictures (and other media)

Resources

Readme
Activity
Custom properties

Stars

1 star

Watchers

4 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.