Amper is a REST-API which converts Markdown text to Google's AMP syntax.
Send a POST request with:
- URL: http://amper.satishyadav.com/amp
- Content-Type:
application/x-www-form-urlencoded
- Parameter "md" with the Markdown syntax.
Output will be amp html.
POST /amp HTTP/1.1
Host: amper.satishyadav.com
Content-Type: application/x-www-form-urlencoded
md=%23+Hello+World%0AThis+was+written+in+**Markdown**
curl -X POST \
http://amper.satishyadav.com/amp \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'md=%23%20Hello%20World%0AThis%20was%20written%20in%20**Markdown**'
var client = new RestClient("http://amper.satishyadav.com/amp");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "md=%23%20Hello%20World%0AThis%20was%20written%20in%20**Markdown**", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "md=%23%20Hello%20World%0AThis%20was%20written%20in%20**Markdown**");
Request request = new Request.Builder()
.url("http://amper.satishyadav.com/amp")
.post(body)
.addHeader("content-type", "application/x-www-form-urlencoded")
.build();
Response response = client.newCall(request).execute();
var data = "md=%23%20Hello%20World%0AThis%20was%20written%20in%20**Markdown**";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "http://amper.satishyadav.com/amp");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.send(data);
var settings = {
"async": true,
"crossDomain": true,
"url": "http://amper.satishyadav.com/amp",
"method": "POST",
"headers": {
"content-type": "application/x-www-form-urlencoded",
},
"data": {
"md": "# Hello World\nThis was written in **Markdown**"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var qs = require("querystring");
var http = require("http");
var options = {
"method": "POST",
"hostname": "amper.satishyadav.com",
"port": null,
"path": "/amp",
"headers": {
"content-type": "application/x-www-form-urlencoded"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(qs.stringify({ md: '# Hello World\nThis was written in **Markdown**' }));
req.end();
var request = require("request");
var options = { method: 'POST',
url: 'http://amper.satishyadav.com/amp',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
form: { md: '# Hello World\nThis was written in **Markdown**' }
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$request = new HttpRequest();
$request->setUrl('http://amper.satishyadav.com/amp');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'content-type' => 'application/x-www-form-urlencoded'
));
$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields(array(
'md' => '# Hello World
This was written in **Markdown**'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
import http.client
conn = http.client.HTTPConnection("amper.satishyadav.com")
payload = "md=%23%20Hello%20World%0AThis%20was%20written%20in%20**Markdown**"
headers = { 'content-type': "application/x-www-form-urlencoded" }
conn.request("POST", "/amp", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
It uses https://github.com/dwyl/ampl library to convert _Markdown_to amp.