jclyo1 commited on
Commit
c9a473f
1 Parent(s): 2da7508
Files changed (3) hide show
  1. Dockerfile +3 -0
  2. main.py +23 -4
  3. static/index.html +11 -3
Dockerfile CHANGED
@@ -50,5 +50,8 @@ WORKDIR $HOME/app
50
  RUN chmod +x scripts/sign.sh
51
  RUN chmod +x scripts/verify.sh
52
  RUN chmod +x scripts/upload.sh
 
 
 
53
 
54
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
50
  RUN chmod +x scripts/sign.sh
51
  RUN chmod +x scripts/verify.sh
52
  RUN chmod +x scripts/upload.sh
53
+ RUN chmod +w scripts/sign.sh
54
+ RUN chmod +w scripts/verify.sh
55
+ RUN chmod +w scripts/upload.sh
56
 
57
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
main.py CHANGED
@@ -94,7 +94,7 @@ def verify_image(fileUpload: UploadFile):
94
  #call steg sign script
95
  response = subprocess.check_output(
96
  [
97
- "./scripts/sign.sh",
98
  fileUpload.filename,
99
  ]
100
  )
@@ -105,7 +105,7 @@ def verify_image(fileUpload: UploadFile):
105
 
106
  @app.post("/sign")
107
  def sign_image(fileUpload: UploadFile):
108
- logging.warning("in verify")
109
  logging.warning(fileUpload.filename)
110
 
111
 
@@ -117,9 +117,28 @@ def sign_image(fileUpload: UploadFile):
117
 
118
  # open read and write the file into the server
119
  open(fn, 'wb').write(fileUpload.file.read())
120
-
121
- return {"response": fileUpload.filename}
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
125
 
 
94
  #call steg sign script
95
  response = subprocess.check_output(
96
  [
97
+ "./scripts/verify.sh",
98
  fileUpload.filename,
99
  ]
100
  )
 
105
 
106
  @app.post("/sign")
107
  def sign_image(fileUpload: UploadFile):
108
+ logging.warning("in sign")
109
  logging.warning(fileUpload.filename)
110
 
111
 
 
117
 
118
  # open read and write the file into the server
119
  open(fn, 'wb').write(fileUpload.file.read())
 
 
120
 
121
+ # subprocess.check_output(
122
+ # [
123
+ # "./truepic",
124
+ # "sign",
125
+ # fileUpload.filename,
126
+ # "--output",
127
+ # (os.getcwd() + "/static/" + fileUpload.filename),
128
+ # ]
129
+ # )
130
+
131
+ #call steg sign script
132
+ response = subprocess.check_output(
133
+ [
134
+ "./scripts/sign.sh",
135
+ fileUpload.filename,
136
+ ]
137
+ )
138
+
139
+ logging.warning(response)
140
+
141
+ return {"response": fileUpload.filename}
142
 
143
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
144
 
static/index.html CHANGED
@@ -27,8 +27,12 @@
27
  </head>
28
  <body>
29
  <div class="container">
 
 
 
 
 
30
  <form method="post" id="fileUploadForm" enctype = "multipart/form-data">
31
- <label class="form-label" for="customFile">Default file input example</label>
32
  <input type="file" class="form-control" name="fileUpload" id="fileUpload" />
33
  <button class="btn btn-primary" type="submit">Submit</button>
34
  </form>
@@ -39,7 +43,8 @@
39
 
40
  <script>
41
  const form = document.querySelector('#fileUploadForm');
42
-
 
43
  form.addEventListener('submit', (e) => {
44
  e.preventDefault();
45
  submitForm();
@@ -56,7 +61,10 @@ function submitForm() {
56
  }
57
 
58
  function submitFormData(formData) {
59
- fetch('/verify', {
 
 
 
60
  method: 'POST',
61
  body: formData
62
  })
 
27
  </head>
28
  <body>
29
  <div class="container">
30
+ <label class="form-label" for="customFile">Operation</label>
31
+ <select class="form-select" id="operation">
32
+ <option value="/verify">Verify</option>
33
+ <option value="/sign">Sign</option>
34
+ </select>
35
  <form method="post" id="fileUploadForm" enctype = "multipart/form-data">
 
36
  <input type="file" class="form-control" name="fileUpload" id="fileUpload" />
37
  <button class="btn btn-primary" type="submit">Submit</button>
38
  </form>
 
43
 
44
  <script>
45
  const form = document.querySelector('#fileUploadForm');
46
+ const operation = document.querySelector('#operation');
47
+
48
  form.addEventListener('submit', (e) => {
49
  e.preventDefault();
50
  submitForm();
 
61
  }
62
 
63
  function submitFormData(formData) {
64
+ console.log("operation", operation.value)
65
+
66
+
67
+ fetch(operation.value, {
68
  method: 'POST',
69
  body: formData
70
  })