这是我的代码:
import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
Run Code Online (Sandbox Code Playgroud)
logIn(username: string, password: string) {
const url = 'http://server.com/index.php';
const body = JSON.stringify({username: username,
password: password});
const headers = new HttpHeaders();
headers.set('Content-Type', 'application/json; charset=utf-8');
this.http.post(url, body, {headers: headers}).subscribe(
(data) => {
console.log(data);
},
(err: HttpErrorResponse) => {
if (err.error instanceof Error) {
console.log('Client-side error occured.');
} else {
console.log('Server-side error occured.');
}
}
);
}
Run Code Online (Sandbox Code Playgroud)
在这里网络调试:
Request Method:POST
Status Code:200 OK
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:46
Content-Type:text/plain …Run Code Online (Sandbox Code Playgroud) 我尝试创建一个简单的烧瓶应用程序:
from flask import Flask
app = Flask(__name__)
if __name__ == '__main__':
app.run()
Run Code Online (Sandbox Code Playgroud)
但是当我添加调试时:
FLASK_APP = run.py
FLASK_ENV = development
FLASK_DEBUG = 1
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
ValueError:signal仅适用于主线程
这里是完整的堆栈跟踪
FLASK_APP = run.py
FLASK_ENV = development
FLASK_DEBUG = 1
In folder c:/MyProjectPath/api
c:\MyProjectPath\api\venv\Scripts\python.exe -m flask run
* Serving Flask-SocketIO app "run.py"
* Forcing debug mode on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 283-122-745
Exception in thread Thread-1:
Traceback (most recent call last):
File "c:\appdata\local\programs\python\python37\Lib\threading.py", line 917, in _bootstrap_inner
self.run() …Run Code Online (Sandbox Code Playgroud) 我知道这已经得到了回答,但我对给出的答案并不满意.
我的问题很简单,用户想要注销.
如果它位于需要登录的页面上(使用auth.service.ts在auth.guard.ts中设置)并且用户注销我希望将其重定向到主页.
但是,如果他在一个安全的页面上,我不想重定向他.
我可以使用AuthGuard,但我不想重新加载页面,所以没有:
location.reload()
Run Code Online (Sandbox Code Playgroud)
我的选择是什么?
我希望通过SSL提供我的应用程序之前我有这个脚本:
ng serve --ssl --ssl-key "pathtokey\key.crt"
Run Code Online (Sandbox Code Playgroud)
我想在新的angular.json中添加SSL但是当我尝试添加它时我得到了错误:
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(ssl).
Run Code Online (Sandbox Code Playgroud)
在角度cli 6中使用SSL的正确方法是什么?
angular ×3
angular-cli ×1
angular6 ×1
flask ×1
http-headers ×1
python ×1
python-3.x ×1
typescript ×1
web ×1