You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.2 KiB

  1. <?php
  2. // get image, wav
  3. $image = $_POST["image"];
  4. $wav_Str = $_POST["wav_Str"];
  5. $title = $_POST["title"];
  6. // replace spaces with +
  7. $data = str_replace(" ", "+", $image);
  8. $wav_data = str_replace(" ", "+", $wav_Str);
  9. $title_data = str_replace(" ", "+", $title);
  10. // decoding base 64
  11. $data = base64_decode($data);
  12. $wav_data = base64_decode($wav_data);
  13. $title_data = base64_decode($title_data);
  14. // saving in file as image
  15. file_put_contents("image.jpg", $data);
  16. file_put_contents("/Users/seungwoomun/Documents/MYC/code/wav/title.wav", $wav_data);
  17. // run python script
  18. exec("cd /Users/seungwoomun/Documents/MYC/code/ && python3 use_Model.py");
  19. // $command = escapeshellcmd("cd /Users/seungwoomun/Documents/MYC/code/ && python3 use_Model.py");
  20. // shell_exec($command.print_pdf("$title_data.wav"));
  21. // $command = escapeshellcmd('/Users/seungwoomun/Documents/MYC/code/use_Model.py');
  22. // $output = shell_exec($command);
  23. // echo $output;
  24. // $pdf->setSourceFile('./airplane_1.pdf');
  25. // pdf 파일 이름 수정
  26. rename("/Users/seungwoomun/Documents/MYC/code/pdf/title.pdf", "/Users/seungwoomun/Documents/MYC/code/pdf/$title_data.pdf");
  27. rename("/Users/seungwoomun/Documents/MYC/code/pdf/title.xml", "/Users/seungwoomun/Documents/MYC/code/pdf/$title_data.xml");
  28. rename("/Users/seungwoomun/Documents/MYC/code/midi/title.mid", "/Users/seungwoomun/Documents/MYC/code/midi/$title_data.mid");
  29. rename("/Users/seungwoomun/Documents/MYC/code/wav/title.wav", "/Users/seungwoomun/Documents/MYC/code/wav/$title_data.wav");
  30. // sending response back
  31. echo "$title_data 변환 완료";
  32. // var express = require('express'); require('dotenv').config();
  33. // var cors = require('cors');
  34. // var mysql = require('mysql');
  35. // var bodyParser = require('body-parser');
  36. // var http = require('http');
  37. // var app = express();
  38. // app.use(bodyParser.urlencoded({ extended: true }));
  39. // app.use(bodyParser.json());
  40. // app.use(bodyParser.raw({ type: 'audio/m4a', limit: '60mb' })) app.use(cors());
  41. // app.post('/addAudio', function (req, res) {
  42. // console.log("Audio is successfully posted!");
  43. // console.log("Obtained audio data: ", req.body);
  44. // });
  45. // app.listen(8080, function () {
  46. // console.log("Server is listening on port 8080!");
  47. // });
  48. ?>