Created
September 5, 2011 18:34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ajax new | |
url: '/my/post/handler'; | |
at: 'type' put: 'post'; | |
at: 'data' put: 'foo'; | |
send. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from werkzeug import secure_filename | |
@app.route("/<filetype>/<filename>", methods=["PUT"]) | |
def commit_changes(filetype, filename): | |
"""Commit changes in the Jtalk image to disk""" | |
filename = secure_filename(filename) | |
data = request.form.keys()[0] | |
with open(os.path.join(UPLOAD_FOLDER, filetype, filename), "w") as fileobject: | |
fileobject.write(data) | |
return "201" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget subclass: #Counter | |
instanceVariableNames: 'count header' | |
category: 'Examples' | |
initialize | |
super initialize. | |
counter := 0. | |
increase | |
count := count + 1. | |
header contents: [ :html | html with: count asString ] | |
decrease | |
count := count - 1. | |
header contents: [ :html | html with: count asString ] | |
renderOn: html | |
html h1 with: count asString. | |
html button | |
with: '++'; | |
onClick: [self increase]. | |
html button | |
with: '--'; | |
onClick: [self decrease] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object subclass: #Data | |
instanceVariableNames: '' | |
category: 'Example' | |
get: docId onSuccess: aBlock | |
|smalltalk| | |
smalltalk := Smalltalk new. | |
Ajax new | |
url: '/get/', docId; | |
onSuccessDo: [ :data | aBlock value: (smalltalk readJson: data) ]; | |
onErrorDo: [ :error | Transcript show: 'Request Failed!' ]; | |
send. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget subclass: #HelloWorld | |
instanceVariableNames: '' | |
category: 'Examples' | |
renderOn: html | |
"Render some html" | |
html div class: 'section'; | |
id: 'headerSection'; | |
with: [ html h1: 'Hello World' ]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object subclass: #Rasta | |
instanceVariableNames: 'rasta' | |
Category: 'Example' | |
initialize | |
super initialize. | |
rasta := <Rasta;>. | |
get: aKey onSuccessDo: aBlock | |
rasta get: aKey value: aBlock | |
set: aKey with: aValue onSuccessDo: aBlock | |
rasta set: aKey value: aValue value: aBlock. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ajax new | |
url: '/my_web_service/get_content'; | |
onSuccessDo: [ :data | Transcript show: data ]; | |
onErrorDo: [ :error | Transcript show: 'Request failed!' ]; | |
send. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Flask import Flask, abort, jsonify | |
from couchdb import Database | |
app = Flask(__name__) | |
database = Database("http://10.0.0.2:5984/my_database") | |
@app.route("/") | |
def index(): | |
"""Show the Jtalk IDE""" | |
return render_template("ide.html") | |
@app.route("/get/<doc_id>") | |
def get_document(doc_id): | |
"""Lookup the document in the database and return it as JSON""" | |
doc = database.get(doc_id) | |
if doc: | |
response = jsonify(doc) | |
else: | |
response = abort(404) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment