type = convert_sightseeing_type(s['type'])
direction = get_direction(coordinate, (s['lat'], s['lon']))
game.tips.append(
- f'Кстати, неподалеку на {convert_direction(direction)}е есть ' + (type if type else 'интересный туристический объект') + ': ' + s["name"])
+ f'Кстати, неподалеку на {convert_direction(direction)}е есть ' + (
+ type if type else 'интересный туристический объект') + ': ' + s["name"])
shuffle(game.tips)
}
-def handle_post_game(city_id):
+@post('/api/games')
+def post_game():
game_id = str(uuid.uuid4())
+ city_id = request.json['city'] or 'Екатеринбург'
if city_id not in cities:
return bottle.HTTPResponse(status=404, body='city not found')
}
-@post('/api/games')
-@enable_cors
-def post_game_without_city():
- return handle_post_game('Екатеринбург')
-
-
-@post('/api/games/<city>')
-@enable_cors
-def post_game(city):
- return handle_post_game(city)
-
-
@get('/api/games/<game_id>')
@enable_cors
def get_game(game_id):
has_more = len([tip for tip in game.tips if tip not in game.shown_tips]) > 0
-
return {'tips': game.shown_tips, 'hasMore': has_more}
def index(whatever):
return static_file('index.html', "build")
+
application = bottle.default_app()
from paste import httpserver
-
if os.environ.get('APP_LOCATION') == 'heroku':
httpserver.serve(application, host='0.0.0.0', port=int(os.environ.get("PORT", 5000)))
else:
disableDotRule: true,
},
public: allowedHost,
- proxy,
+ proxy: {
+ '/api': {target: 'http://localhost:8080/'}
+ },
before(app, server) {
if (fs.existsSync(paths.proxySetup)) {
// This registers user provided middleware for proxy reasons
}
componentDidMount() {
- this.gameController.createGame().then(() => this.gameController.loadTips()).then(() => {
+ this.gameController.createGame('Екатеринбург').then(() => this.gameController.loadTips()).then(() => {
this.setState({
tips: this.handleVarlamov(this.gameController.tips()),
hasMoreTips: this.gameController.hasMoreTips(),
loading: false,
inProcess: false
}, () => {
- createMap('map', this.onMapClick);
+ createMap('map', this.onMapClick, this.gameController.getBoundaries());
})
}).catch(error => {
this.notification.show(
this.notification = notification;
}
- createGame() {
- return api.post('/games').then(json => {
+ createGame(city) {
+ return api.post('/games', {city: city}).then(json => {
this.gameId = json.data.game_id;
+ this.minLat = json.data.min_lat;
+ this.maxLat = json.data.max_lat;
+ this.minLon = json.data.min_lon;
+ this.maxLon = json.data.max_lon;
});
}
tryFinish(ltLng) {
return api.post(`/games/${this.gameId}/finish/${ltLng}`);
}
+
+ getBoundaries() {
+ return [[this.minLat, this.minLon], [this.maxLat, this.maxLon]];
+ }
}
import * as axios from 'axios';
export const api = axios.create({
- baseURL: process.env.NODE_ENV === 'production' ? '/api/': 'http://localhost:8080/api/',
- timeout: 30000
+ baseURL: process.env.NODE_ENV === 'production' ? '/api/': '/api/',
+ timeout: 60000
});
\ No newline at end of file
SW: ['56.768982', '60.491112']
};
-export function createMap(elementId, onMapClick) {
- const neLat = ekb.NE[0];
- const neLng = ekb.NE[1];
- const swLat = ekb.SW[0];
- const swLng = ekb.SW[1];
+export function createMap(elementId, onMapClick, boundaries) {
+ const neLat = boundaries[0][0];
+ const neLng = boundaries[0][1];
+ const swLat = boundaries[1][0];
+ const swLng = boundaries[1][1];
const map = new L.Map(elementId);