Is it possible in express JS to only accept one of two values in a path variable?

Advertisements Let’s say I have this GET url in my REST service: router.get(‘/api/platform/:type’, async (req, res) => { // something } I only want the request if :type is "windows" or "android". are there any way to do this in the url definition? I think I’ve seen something like this before: router.get(‘/api/platform/:type{windows|android}’, async (req, res)… Read More Is it possible in express JS to only accept one of two values in a path variable?

React useParams returns undefined

Advertisements I’m writing a React app. I need to capture the url params using useParams(). Below is the relevant code: import { BrowserRouter as Router, Route, Routes , useParams} from ‘react-router-dom’; function App() { const {id} = useParams(); console.log(id) }; return ( <Router> <Routes> <Route path=”:id” element={<Form/>} > </Route> </Routes> </Router> ); } export default… Read More React useParams returns undefined

How to import data from a url to pandas dataframe?

Advertisements I’m trying to import data from the following url into pandas dataframe: https://www.asx.com.au/data/shortsell.txt I tried the following: url = ‘https://www.asx.com.au/data/shortsell.txt&#8217; reader = pd.read_table(url, sep=’\t’, skiprows=lambda x: x in [0, 1, 2, 3, 4, 5, 6, 7], header=None, names=[ ‘ASX’, ‘Company Name’, ‘Product/’, ‘Reported Gross’, ‘Issued’, ‘% of issued capital’]) I expected to get data… Read More How to import data from a url to pandas dataframe?

PHP detect if slug URL starts with ES/ or EN/

Advertisements I need to detect the language the user is using to include the correct file using PHP if elseif or else like this: users are comming from: example.com/EN/nice-title-url-from-database-slug example.com/DE/nice-title-url-from-database-slug example.com/ES/nice-title-url-from-database-slug the php I need is something like this: PHP document.location.toString().split(…) etc detect the url paths if url path <starts with /DE/> include de.php elseif… Read More PHP detect if slug URL starts with ES/ or EN/