tiangolo / full-stack-flask-couchdb

Full stack, modern web application generator. Using Flask, CouchDB as database, Docker, Swagger, automatic HTTPS and more.
MIT License
31 stars 10 forks source link

Problem with fastAPI and couchdb (sign up api) #5

Closed ElSerpiente63 closed 1 year ago

ElSerpiente63 commented 2 years ago

Hello everyone, I am trying to do a sign up API with python and the library fastAPI with a couchdb database. So the front makes a post request with json, and the api put it on database. But I did a code and it just doesn't work. Here is the code :

from fastapi import FastAPI, Body 
import uvicorn
from typing import Union
from pydantic import BaseModel
from typing import Optional
import couchdb
from couchdb import Server

api = FastAPI() #on instancie 

class User_register(BaseModel):
    first_name: str
    last_name: str
    gender: str
    age: int
    address:str 
    e_mail:  str

@api.post('/postuserinfo')
def create_post(payload: dict = Body(...)):
    couch_data = 'http://admin:pass@localhost:5984/db_reviewin'
    couch_data.save(payload)
    return {"Status":"Done"}  

if __name__ == '__main__':
    uvicorn.run(api, host= '127.0.0.1', port= 8000)
tiangolo commented 1 year ago

Hey there, I'm sorry, I'm no longer using this project for a long while, so I won't be able to help you.

Also, this project is based on Flask, not FastAPI, you would probably find more help asking in the FastAPI repo or Discord.

Given all that, I'm gonna close this one. :coffee: