Lance-Tsui / cambioml

0 stars 0 forks source link

Store uploaded files in the frontend? #2

Open CambioML opened 1 month ago

CambioML commented 1 month ago

In your backend, it looks like it is invoking frontend server https://github.com/Lance-Tsui/cambioml/blob/main/python/ocr.py#L28-L38 to downloads file. Why not store files in the backend server instead of frontend? What is your design concept here and what kinds of improvement that you can think about proposing.

Lance-Tsui commented 1 month ago

Sorry, I mixed up the frontend and backend in my earlier explanation. The PHP is the frontend and the Python is the backend.

Lance-Tsui commented 1 month ago

The PHP frontend displays the user interface. In index.php, when user uploads a file, the upload.php uploads the file to php's upload folder and sends a request $url = 'http://victsoi.pythonanywhere.com/ocr?filename=' . urlencode($newFilename); to the python backend. The backend Python server is also always running so that it will receive such request. The current python code copies the uploaded file to its 'uploads' folder first (but this is due to my python web space permissions, if I got a more time I will find a server to allow the php uploading to the python backend's hosting space directly), then the python backend does the image processing via google api.

Lance-Tsui commented 1 month ago

I'm also learning mongodb these days. So for potential database solutions, what I will use is using mongodb atlas, creating a collection (table) in mongodb, and add the following fields

Lance-Tsui commented 1 month ago

see sample connection configuration: from pymongo.mongo_client import MongoClient uri = "mongodb+srv://usernamel:@db.0owihzx.mongodb.net/?retryWrites=true&w=majority&appName=db"

client = MongoClient(uri) try: client.admin.command('ping') print("Pinged your deployment. You successfully connected to MongoDB!") except Exception as e: print(e)