Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Python FastAPI question: How do I achieve route aliasing in FASTAPI

$
0
0

I just started learning about FastAPI and I have this issue where I need your kind help.

Let's say I am creating a page based on some image IDs (img001, img002, ... etc.) which are saved in a database with relevant information like location, country, date, path, resolution etc. There are 1500+ images.

I want to write a script index.py under /photo directory which is like http://localhost:8000/photo/?id=img001 which will read the database table for imageID = img001 and will show all the above information/metadata for that image.

I would like to automatically create aliases like below:

http://localhost:8000/myimage/001    -> http://localhost:8000/photo/?id=img001http://localhost:8000/myimage/002    -> http://localhost:8000/photo/?id=img002http://localhost:8000/myimage/003    -> http://localhost:8000/photo/?id=img003

There is a separate system to add the images into the database and that is dynamic and anytime a new image can come so I cannot configure and populate these aliases beforehand - they need to be dynamically aliased like above.

How can I achieve this?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>