Question: I'm trying to server an HTML page with some Javascript from a Flask Server

Python Code:

```
from flask import Flask
from flask import render_template
app = Flask(__name__)

@app.route("/")
def hello():
    return render_template('simple.html')

if __name__ == "__main__":
    app.run()

```

My directory looks something like this:

[![enter image description here](https://i.stack.imgur.com/0zAZo.png)](https://i.stack.imgur.com/0zAZo.png)

The HTML file I'm rendering is in the templates file. 

To load the JS file I have `<script type="text/javascript" src="../static/js/script.js"></script>`

I keep getting an error 

```
"browser.min.js:3 GET http://localhost:5000/script.js 404 (NOT FOUND)n.load @ browser.min.js:3s @ browser.min.js:3i @ browser.min.js:3
browser.min.js:3 Uncaught Error: Could not load http://localhost:5000/script.js(…)s.onreadystatechange @ browser.min.js:3

```

What am I doing wrong?

Answer: 
At the start of your main method:

```
    Pattern p = Pattern.compile("(.*)([+-].*)i");
    double real, imaginary;

```

Then in `case 1:`

```
    System.out.println("Enter first complex number: ");

    real = 0.0;
    imaginary = 0.0;
    Matcher m = p.match(get.nextLine()); // read the user input as a string
    if (m.matches()) { // if the user input matches the required pattern
        real = Double.parseDouble(m.group(1)); // extract the real part
        imaginary = Double.parseDouble(m.group(2)); // extract the imaginary part
    }
    Complex c1 = new Complex(real, imaginary); // build the Complex object

    System.out.println("Enter Second complex number: ");

    real = 0.0;
    imaginary = 0.0;
    Matcher m = p.match(get.nextLine());
    if (m.matches()) {
        real = Double.parseDouble(m.group(1));
        imaginary = Double.parseDouble(m.group(2));
    }
    Complex c2 = new Complex(real, imaginary);

    Complex c3 =c1.add(c2);

```

You'll probably want to add some error handling if the user's input doesn't match the required pattern (otherwise `real` and `imaginary` will both be 0).
Here is something if you have integer parts. Please amend for doubles.

```
Complex c1;
Scanner sline = new Scanner(System.in);
Pattern p = Pattern.compile("(\+|-){0,1}\\d+[ ]*(\+|-)[ ]*(i\\d+|\\d+i)");
if(sline.hasNext(p)) {
    String str = sline.next(p).replace("+"," +").replace("-"," -");
    Scanner sc = new Scanner(str);
    int r = sc.nextInt();
    int i = Integer.parseInt(sc.next().replace('i',''));
    c1 = new Complex(r, i);
}

```