Skip to content

Commit c2bd7e6

Browse files
committed
Merge pull request #3 from kap0w/master
Fixed JSON bug and made a short explanation about API
2 parents e11aecf + d24f527 commit c2bd7e6

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ If you want to run the site on a different port, use the -p parameter.
2121

2222
bundle exec rails server -p 80
2323

24+
## API
25+
26+
You can generate passwords through an API, if you want to automate creation, it is done by hitting the password action with a POST-request. In the development environment you can use this address: http://127.0.0.1:3000/passwords.json
27+
28+
And you will have to send these POST variables:
29+
30+
password[payload]: test
31+
32+
password[expire_after_days]: 60
33+
34+
password[expire_after_views]: 1337
35+
36+
You can test it in your browsers javascript console by going to the frontpage of Password Pusher and type:
37+
38+
$.post('http://127.0.0.1:3000/passwords.json',{ 'password[payload]': 'test', 'password[expire_after_days]': '60', 'password[expire_after_views]': '1337' }, function(data) { alert(data.url_token) } )
39+
40+
Or do it with curl:
41+
42+
curl -d -X POST --data "password[payload]=payload&password[expire_after_days]=60&password[expire_after_views]=1337" http://127.0.0.1:3000/passwords.json
43+
2444
## Potential Quick Start Errors
2545

2646
### Command not found: bundle

app/controllers/passwords_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def create
105105
respond_to do |format|
106106
if @password.save
107107
format.html { redirect_to "/p/#{@password.url_token}", :notice => "The password has been pushed." }
108-
format.json { render :json => @password, :status => :created, :location => @password }
108+
format.json { render :json => @password, :status => :created }
109109
else
110110
format.html { render :action => "new" }
111111
format.json { render :json => @password.errors, :status => :unprocessable_entity }

db/schema.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# encoding: UTF-8
12
# This file is auto-generated from the current state of the database. Instead
23
# of editing this file, please use the migrations feature of Active Record to
34
# incrementally modify your database, and then regenerate this schema definition.

0 commit comments

Comments
 (0)