title: How to serve uploaded image using Sanic?
body: <p>I have successfully uploaded image in a certain directory in my project using Sanic. The code that I used to upload image is as follows:</p>
  
  <pre><code>class ImageUploadAPI(HTTPMethodView):
      async def post(self, request):
          access_token = get_token_from_header(request.headers)
          token = decode_token(access_token)
          user_id = token.get('sub')
          upload_file = request.files.get('image')
          log_path = os.path.join(os.getcwd(), 'pictures')
          if not os.path.exists(log_path):
              os.makedirs(log_path)
  
          if not upload_file:
              res = {'status': 'no file uploaded'}
              return json(res, status=404)
  
      # if not valid_file_type(upload_file.name, upload_file.type):
      #     res = {'status': 'invalid file type'}
      #     return json(res, status=400)
          elif not valid_file_size(upload_file.body):
              res = {'status': 'invalid file size'}
              return json(res, status=400)
          else:
              file_path = f"{log_path}/{str(datetime.now())}.{upload_file.name.split('.')[1]}"
              await write_file(file_path, upload_file.body)
              await apps.db.users.update_one({'_id': ObjectId(user_id)}, {"$set": {
              "nid_front": upload_file.name
              }})
              return json({'status': 'image uploaded successfully'})
  </code></pre>
  
  <p>In this process I have saved the <code>upload_file.name</code> in a <code>user</code> field.
  Now to serve the uploaded image, I have accessed the following url(<em>as i am in local server</em>) <a href="http://localhost:8000/10414532_479247615552487_2110029531698825823_n.jpg" rel="nofollow noreferrer">http://localhost:8000/10414532_479247615552487_2110029531698825823_n.jpg</a>
  but it doesn't show the image instead showing that,</p>
  
  <pre><code>Error: Requested URL /10414532_479247615552487_2110029531698825823_n.jpg not found
  </code></pre>
  
  <p>How can I serve the uploaded image ?</p>