title: FastAPI - dynamic inputs for different data types
body: <p>I have to create a very generic endpoint for a user. The user may send <code>JSON</code> data or may upload a <code>file</code> to this endpoint.</p>
  <p>There are multiple options on how to handle different input types, like <code>Request</code> or <code>UploadFile</code></p>
  <p>I thought about solving it like this (pseudo code):</p>
  <pre class="lang-py prettyprint-override"><code>from enum import Enum
  
  class Multiple(Enum):
      request: Request
      file: UploadFile
  
  @app.post(&quot;/&quot;)
  async def root(Multiple):
      if Multiple == request:
          do xxx 
      else if Multiple == file:
          do yyyy
      else: 
          do zzz
  </code></pre>
  <p>Is there any way to make something like this work?</p>