I have a problem, when giv my Falsk py to cloud serve phytonanywhere.com works at Hi, I have a problem, when I giv my Falsk py to cloud serve phytonanywhere.com works at Chrome, but not works at app.
This is my flask_app.py
from flask import Flask, jsonify,request
from posts import posts
app=Flask(__name__)
@app.route('/')
def index():
lang = request.headers.get("Accept-Language", 'sk')[:2]
p = list(map (lambda post: translate(post, lang), posts))
return jsonify(p)
def translate(post, lang):
translation = next (t for t in post['translations'] if t['locale'] == lang)
return {
"id": post ['id'],
"title": translation ['title'],
"description": translation ['description'],
"image": post['image'],
}
Works at Chrome, I see this.
And my app code is
import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Component({
selector: 'app-posts2',
templateUrl: './posts.component.html',
styleUrls: ['./posts.component.scss'],
})
export class PostsComponent implements OnInit {
posts:any = [];
constructor(private http: HttpClient) { }
ngOnInit() {
const lang = localStorage.getItem('lang') || 'sk';
const headers = new HttpHeaders({
'Accept-Language': lang
})
this.http.get('http://miki83.pythonanywhere.com/', {
headers: headers
}).subscribe(data=>{
console.log();
this.posts = data;
});
}
}
when I run my application real on Android Studio Drive then I have empty screen.
I have this cloud on my application on butoon click
How is problem? I paste the cloud Url to app.