-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
36 lines (30 loc) · 818 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from fastapi import FastAPI
from pydantic import BaseModel
from fastapi.encoders import jsonable_encoder
from fastapi.middleware.cors import CORSMiddleware
import random
from datetime import datetime
import json
from fastapi.responses import HTMLResponse
pp = FastAPI()
origins = ["*"]
pp.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=['*'],
allow_headers=['*'],
)
class villagers(BaseModel):
email: str
password: str
@pp.post('/home')
def signup(villagers: villagers):
enc = jsonable_encoder(villagers)
v_name = enc['email']
password = enc['password']
d = {
"email": v_name,
"password": password,
}
return 'hello '+v_name+'you have been registered,go to the Login page to Login'