tiangolo / full-stack-flask-couchdb

Full stack, modern web application generator. Using Flask, CouchDB as database, Docker, Swagger, automatic HTTPS and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with fastAPI and couchdb (sign up api)

ElSerpiente63 opened this issue · comments

commented

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)

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. ☕