ajout dev docker
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from fastapi import FastAPI
|
||||
from pymongo import MongoClient
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# MongoDB connection
|
||||
client = MongoClient("mongodb://mongodb:27017/")
|
||||
db = client.memes_db
|
||||
|
||||
@app.get("/memes")
|
||||
def get_memes():
|
||||
memes = list(db.memes.find({}, {"_id": 0}))
|
||||
return {"memes": memes}
|
||||
|
||||
@app.post("/memes")
|
||||
def create_meme(title: str, url: str):
|
||||
meme = {"title": title, "url": url}
|
||||
db.memes.insert_one(meme)
|
||||
return {"message": "Meme added successfully"}
|
||||
Reference in New Issue
Block a user