Update main.py
Browse files
main.py
CHANGED
@@ -9,14 +9,18 @@ from auth import verify_token, oauth2_scheme, auth_views, register, UserCreate,
|
|
9 |
from database import get_db, get_user_by_email
|
10 |
from datetime import timedelta
|
11 |
from typing import Optional
|
12 |
-
import
|
13 |
#import auth
|
14 |
#import tts
|
15 |
import os
|
16 |
import asyncio
|
17 |
|
18 |
my_secret_key = os.environ['my_secret_key']
|
|
|
|
|
19 |
app = FastAPI()
|
|
|
|
|
20 |
#router = APIRouter()
|
21 |
templates = Jinja2Templates(directory="templates")
|
22 |
|
@@ -154,16 +158,17 @@ async def register_post(
|
|
154 |
db: Session = Depends(get_db)
|
155 |
):
|
156 |
# Perform reCAPTCHA verification first
|
157 |
-
|
158 |
-
recaptcha_key = '6LdMjQcpAAAAAGtbNZkL17ry1scsQjp1HSEhkLNl' # Replace with your site key
|
159 |
-
recaptcha_action = 'submit' # The action you're expecting
|
160 |
recaptcha_secret = '6LdMjQcpAAAAAGtbNZkL17ry1scsQjp1HSEhkLNl' # Replace with your reCAPTCHA secret key
|
161 |
recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'
|
162 |
recaptcha_data = {
|
163 |
'secret': recaptcha_secret,
|
164 |
'response': recaptcha_token
|
165 |
}
|
166 |
-
|
|
|
|
|
|
|
167 |
recaptcha_result = recaptcha_response.json()
|
168 |
|
169 |
if not recaptcha_result.get('success', False):
|
|
|
9 |
from database import get_db, get_user_by_email
|
10 |
from datetime import timedelta
|
11 |
from typing import Optional
|
12 |
+
import httpx
|
13 |
#import auth
|
14 |
#import tts
|
15 |
import os
|
16 |
import asyncio
|
17 |
|
18 |
my_secret_key = os.environ['my_secret_key']
|
19 |
+
from fastapi.staticfiles import StaticFiles
|
20 |
+
|
21 |
app = FastAPI()
|
22 |
+
|
23 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
24 |
#router = APIRouter()
|
25 |
templates = Jinja2Templates(directory="templates")
|
26 |
|
|
|
158 |
db: Session = Depends(get_db)
|
159 |
):
|
160 |
# Perform reCAPTCHA verification first
|
161 |
+
|
|
|
|
|
162 |
recaptcha_secret = '6LdMjQcpAAAAAGtbNZkL17ry1scsQjp1HSEhkLNl' # Replace with your reCAPTCHA secret key
|
163 |
recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'
|
164 |
recaptcha_data = {
|
165 |
'secret': recaptcha_secret,
|
166 |
'response': recaptcha_token
|
167 |
}
|
168 |
+
|
169 |
+
async with httpx.AsyncClient() as client:
|
170 |
+
recaptcha_response = await client.post(recaptcha_url, data=recaptcha_data)
|
171 |
+
|
172 |
recaptcha_result = recaptcha_response.json()
|
173 |
|
174 |
if not recaptcha_result.get('success', False):
|