api.js 887 B

12345678910111213141516171819202122232425
  1. module.exports = require('./header.js') +`
  2. <p>alias pastit="curl -X POST 'http://localhost:3003/pastit?apiKey=__KEY__' --data-binary '@-'"</p>
  3. <p>ls -l | pastit</p>
  4. <input type="text" placeholder="Your API key will show here" id="apiResult" disabled />
  5. <form id="form" action="#" method="POST">
  6. <div id="error" class="hidden"></div>
  7. <button class="g-recaptcha" data-sitekey="{reCaptcha_public}" data-callback="onSubmit" data-action="submit">Submit</button>
  8. </form>
  9. <script>
  10. function onSubmit(token) {
  11. $.post(document.location.href, $("#form").serialize(), data => {
  12. if (data.err) {
  13. $("#error").text("Error: " +data.err).removeClass("hidden");
  14. } else if (data.id) {
  15. $("#error").text("").addClass("hidden");
  16. $("#apiResult").val(data.id);
  17. console.log(data.id);
  18. }
  19. });
  20. }
  21. </script>
  22. ` + require('./footer.js');