我读到了一些与在本地存储中存储 jwt 令牌相关的问题,这就是我尝试将令牌存储在仅 http cookie 中的原因。我正在使用以下方法。
from rest_framework.views import APIView
from rest_framework.response import Response
import jwt
from django.conf import settings
from rest_framework import status
class LoginView(APIView):
def post(self, request, format=None):
email = request.data['email']
password = request.data['password']
# dummy user authentication
if email == 'email' and password == 'password':
encoded = jwt.encode(
{'email': email}, settings.SECRET_KEY, algorithm='HS256')
response = Response()
response.set_cookie(key='token', value=encoded, httponly=True)
response.data = {
'user': email,
}
return response
else:
return Response({'error': 'wrong credentials'}, status=status.HTTP_401_UNAUTHORIZED)
Run Code Online (Sandbox Code Playgroud)
问题 1:这是使用 django Rest 框架设置 …
python authentication django cookie-httponly django-rest-framework
我使用GCC编译器在CMD上编译并运行C程序。当我使用命令编译 C 程序时,gcc hello.c它会创建一个名为 file 的可执行文件a.exe,但当我使用 IDE 时,它使用与 .c 文件相同的名称hello.exe。是否可以在CMD上创建与.c文件名相同的.exe文件?
我只是想知道谁是C和C++的所有者,比如Oracle是Java的所有者,他们发布了新版本的Java.那么谁可以为C和C++提供更新.
正如书中所写——
问题在于区分输入的结尾和有效数据。解决方案是,当没有更多输入时,getchar 返回一个独特的值,该值不能与任何实际字符混淆。该值称为 EOF,即“文件结束”。我们必须将 c 声明为一个足够大的类型,以容纳 getchar 返回的任何值。我们不能使用 char,因为除了任何可能的 char 之外,c 还必须足够大才能容纳 EOF。因此我们使用 int。
main()
{
int c;
c = getchar();
while(c != EOF) {
putchar(c);
c = getchar();
}
}
Run Code Online (Sandbox Code Playgroud)
我无法理解使用 int 而不是 char 的实际原因。EOF 将返回无法存储在 char 中的内容。