routes

Flask route giving 404 with floating point numbers in the URL

吃可爱长大的小学妹 提交于 2019-12-01 15:13:01
问题 I have the following route definition in my Flask app's server.py: @app.route('/nearby/<float:lat>/<float:long>') def nearby(lat, long): for truck in db.trucks.find({'loc': {'$near': [lat, long]}}).limit(5): if truck.has_key('loc'): del truck['loc'] return json.dumps(trucks) But when I go to http://localhost:5000/nearby/37.7909470419234/-122.398633589404 , I get a 404. The other routes work fine, so it's an issue with this one. What am I doing wrong here? 回答1: The built-in FloatConverter does

“/#action” Route in Routes.rb in Ruby on Rails

不打扰是莪最后的温柔 提交于 2019-12-01 15:10:34
How can I create a route of this format (in Ruby on Rails routes.rb file): /#action/id Specifically with the "#" character inserted before the action controller...for example, see http://lala.com/#album/some-album-id thanks! The actual URL you are visiting there is http://lala.com/ . The server does not see the #album/some-album-id piece, the fragment identifier . That is seen solely by the browser. There is a growing trend of building MVC apps with the views and controllers in the client/browser, rather than on the server. The application is implemented with JavaScript in the client, instead

Create RouteValueDictionary with multivalued keys

一曲冷凌霜 提交于 2019-12-01 15:08:56
I'd like to return a RedirectToRouteResult that sends users to a URL like the following: /MyController/MyAction/id?newid=3&newid=5&newid=7 The newid parameter has several values. My call looks like: return RedirectToAction(string.Empty, routeValues); Here is what I have tried so far, and that do not work: // ...?newid%5B0%5D=3&newid%5B1%5D=5&newid%5B2%5D=7 var routeValues = new RouteValueDictionary { {"id", myid}, {"newid[0]", 3}, {"newid[1]", 5}, {"newid[2]", 7}, }; // ...?newid=System.Int32%5B%5D var routeValues = new { id = myid, newid = new int[] { 3, 5, 7 } }; // ...?newid=System.String

Can't route properly in Laravel

﹥>﹥吖頭↗ 提交于 2019-12-01 14:46:52
I am very new to laravel and I simply don't get how to route properly, am completely lost. The problem is I can only route a view to localhost/public. For example I can't route a view to "localhost/public/something" . Am not even sure my urls are correct. If i leave "something.php" empty nothing will show, but if i add some html it shows only the html no views . Am sure am doing it all wrong. So how does one route a view to a page other than "public/". The routing for index is Route::get('/', function(){ return View::make('welcome'); }); works okay. Now how can I achieve the same if do Route:

How to get form data from input as variable in Flask?

北城余情 提交于 2019-12-01 14:41:52
I'm working on a simple UI to start and stop games by ID. The basic HTML I have written is as follows ( game_id is populated by JS): <div align="center" class="top"> <div align="left" class="game-id-input"> Game ID: <input type="text" name="game_id" id="game_id"> </div> <div align="right" class="buttons"> <form action="{{ url_for('start_game', game_id=game_id) }}" method="get"> <input type="submit" name="start" value="Start game" class="btn btn-success"></input> </form> <form action="{{ url_for('end_game', game_id=game_id) }}" method="get"> <input type="submit" name="end" value="End game"

how to remove action name from URL in cakephp2

久未见 提交于 2019-12-01 14:24:22
may be duplicate but I don't get any proper answer or help actually I want to do like: my current URL is : http://mysite.com/MyController/view/page1 but I want something like : http://mysite.com/MyController/page1 means I want to hide action name from URL. I have used Router::connect('/:controller/:id',array('action' => 'view'),array('id' => '[0-9]+')); but its not working for me below one working fine but Router::connect('/:controller/*', array('action' => 'view'),array('id' => '[0-9]+')); it applies for all controller but I wanted to apply for specific controller use Router::connect('

How can I define a route differently if parameter is not integer

蹲街弑〆低调 提交于 2019-12-01 14:13:34
问题 I am using Laravel 5 and working on my local. I made a route with a parameter of {id} and another route with a specific name like so : Route::get('contacts/{id}', 'ContactController@get_contact'); Route::get('contacts/new', 'ContactController@new_contact'); My problem here is that if I try to go at localhost/contacts/new it will automatically access to the get_contact method. I understand that I have made a {id} parameter but what if I want to call get_contact only if my parameter is an

Dynamically change components but have same url displayed on address bar

删除回忆录丶 提交于 2019-12-01 14:12:24
I have a router outlet that would toggle between various components like table, chart, list etc. I have a requirement to not show url change on the address bar. Suppose if table path is http://mysite/table and chart is http://mysite/chart , it should always show http://mysite without displaying relative path change. I think it doesn't make sense to have same url but wants to use a router outlet. Looking for any ideas to achieve that using angular to change components. (even without router is okay) Use skipLocationChange as described here https://angular.io/api/router/NavigationExtras 来源: https

How to apply multiple filters on route group in Laravel 4?

雨燕双飞 提交于 2019-12-01 13:59:52
Goal : I want to make route filter in Laravel 4 using Route::group and Route::filter Description I have 2 types of user : Internal Distributor For, Internal , I have 2 groups: admin regular For Distributor , I have 4 groups: gold silver bronze oem Eligible Route OEM Distributor are eligible for only 5 routes. Route::get('distributors/{id}', array('before' =>'profile', 'uses'=>'DistributorController@show')); Route::get('distributors/{id}/edit', 'DistributorController@edit'); Route::put('distributors/{id}/update', array('as'=>'distributors.update', 'uses'=>'DistributorController@update')); Route

Rails initializer that runs *after* routes are loaded?

こ雲淡風輕ζ 提交于 2019-12-01 13:49:20
问题 I want to set a class attribute when my Rails app starts up. It requires inspecting some routes, so the routes need to be loaded before my custom code runs. I am having trouble finding a reliable place to hook in. This works PERFECTLY in the "test" environment: config.after_initialize do Rails.logger.info "#{Rails.application.routes.routes.map(&:path)}" end But it doesn't work in the "development" environment (the routes are empty) For now I seem to have things working in development mode by